indextracker

package
v0.1.0-alpha.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

pkg/controller/indextracker

Index synchronization tracker.

Overview

Tracks when all resource types have completed initial synchronization.

Quick Start

tracker := indextracker.NewIndexTracker(bus, logger, resourceTypes)
go tracker.Start(ctx)

Events

  • Subscribes: ResourceSyncCompleteEvent
  • Publishes: IndexSynchronizedEvent

License

See main repository for license information.

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

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL