Documentation
¶
Overview ¶
Package indextracker provides the IndexSynchronizationTracker that monitors resource watcher synchronization and publishes an event when all are synced.
The tracker:
- Subscribes to ResourceSyncCompleteEvent
- Tracks which resource types have completed initial sync
- Publishes IndexSynchronizedEvent when ALL resources are synced
- Allows the controller to wait for complete data before reconciliation
Index ¶
- type IndexSynchronizationTracker
- func (t *IndexSynchronizationTracker) AllSynced() bool
- func (t *IndexSynchronizationTracker) GetAllResourceCounts() map[string]int
- func (t *IndexSynchronizationTracker) GetResourceCount(resourceTypeName string) (int, error)
- func (t *IndexSynchronizationTracker) IsResourceSynced(resourceTypeName string) bool
- func (t *IndexSynchronizationTracker) Start(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexSynchronizationTracker ¶
type IndexSynchronizationTracker struct {
// contains filtered or unexported fields
}
IndexSynchronizationTracker monitors resource synchronization and publishes an event when all resource types have completed initial sync.
func New ¶
func New( eventBus *busevents.EventBus, logger *slog.Logger, resourceNames []string, ) *IndexSynchronizationTracker
New creates a new IndexSynchronizationTracker.
Parameters:
- eventBus: EventBus for publishing/subscribing to events
- logger: Logger for diagnostic messages
- resourceNames: List of resource type names that must sync (from Config.WatchedResources keys)
The tracker expects to receive a ResourceSyncCompleteEvent for each resource type in resourceNames before publishing IndexSynchronizedEvent.
func (*IndexSynchronizationTracker) AllSynced ¶
func (t *IndexSynchronizationTracker) AllSynced() bool
AllSynced returns true if all expected resources have synced.
func (*IndexSynchronizationTracker) GetAllResourceCounts ¶
func (t *IndexSynchronizationTracker) GetAllResourceCounts() map[string]int
GetAllResourceCounts returns a map of all resource counts.
Returns a copy to prevent external modification.
func (*IndexSynchronizationTracker) GetResourceCount ¶
func (t *IndexSynchronizationTracker) GetResourceCount(resourceTypeName string) (int, error)
GetResourceCount returns the number of resources loaded during initial sync.
Returns:
- count if the resource has synced
- 0 and error if resource hasn't synced or is unknown
func (*IndexSynchronizationTracker) IsResourceSynced ¶
func (t *IndexSynchronizationTracker) IsResourceSynced(resourceTypeName string) bool
IsResourceSynced returns true if the specified resource type has synced.
func (*IndexSynchronizationTracker) Start ¶
func (t *IndexSynchronizationTracker) Start(ctx context.Context) error
Start begins monitoring resource synchronization events.
This method:
- Tracks which resources have synced
- Publishes IndexSynchronizedEvent when all expected resources are synced
- Runs until ctx is cancelled