everettraven / everettraven/telescopia

Allow users to define the method used to generate an informer's key

Open
#6 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
0
Forks
2
PR merge metrics
No merged PRs in 30d

Description

## Description

Currently the dynamic cache uses a hard-coded method for generating an informer's unique key when generating and adding a new informer to the cache. This logic can be seen here: https://github.com/everettraven/telescopia/blob/main/pkg/cache/cache.go#L347

To help operator authors have more control over the key used and be able to easily reproduce the key when needed, we should allow the user to define the key generation function used by the dynamic cache.

To do this we need to add a new type definition similar to: https://github.com/everettraven/telescopia/blob/c76339b193e66f424af9731b866c050b12169339/pkg/cache/cache.go#L28

This type definition would likely look similar to:

type ScopeInformerKeyFactory func(obj client.Object) string

Next we also need to add a field to the ScopedCache struct like: https://github.com/everettraven/telescopia/blob/c76339b193e66f424af9731b866c050b12169339/pkg/cache/cache.go#L53-L57

Then we would need to add a configuration function that satisfies the ScopedCacheOption type like:
https://github.com/everettraven/telescopia/blob/c76339b193e66f424af9731b866c050b12169339/pkg/cache/cache.go#L68-L75

Lastly we need to utilize the new function in the ScopedCache.GetInformer function

## Acceptance Criteria
- New Go type created to represent the function definition needed
- New field in the ScopedCache struct to hold the function implementation provided
- New ScopedCacheOption implementation to configure this on a ScopedCache object
- Updated ScopedCache.GetInformer implementation to utilize the new function
- Unit tests

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in pkg/cache/cache.go, reviewing the existing informer key generation near ScopedCache.GetInformer and the ScopedCacheOption definitions. Add the requested function type, struct field, and configuration option, then update GetInformer to use it. Done means the acceptance criteria are met and unit tests cover the configurable key-generation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.