indextracker

package
v0.2.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

pkg/controller/indextracker

Initial-sync tracker for the configured resource watchers.

Overview

IndexSynchronizationTracker waits until every watched resource type has reported its initial list-and-watch sync, then fires a single IndexSynchronizedEvent. The reconciler uses that event as the cue to start reconciling — it prevents partial renders that would happen if some informer caches weren't populated yet.

The tracker is constructed with the list of resource-type names that must sync (typically the keys of spec.watchedResources from the CRD plus any controller-internal types like haproxy-pods). Each ResourceSyncCompleteEvent ticks one entry; once they're all checked off, the event fires exactly once.

Quick Start

import "gitlab.com/haproxy-haptic/haptic/pkg/controller/indextracker"

tracker := indextracker.New(bus, logger, []string{
    "ingresses", "services", "endpoints", // from Config.WatchedResources
    "haproxy-pods",                       // controller-internal
})
go tracker.Start(ctx)

The constructor returns *IndexSynchronizationTracker (not IndexTracker); the function name is New, not NewIndexTracker.

Events

  • Subscribes: ResourceSyncCompleteEvent
  • Publishes: IndexSynchronizedEvent (once, when the last expected resource finishes its initial sync)

License

Apache-2.0 — see root LICENSE.

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

View Source
const ComponentName = "index-tracker"

ComponentName is the unique identifier for the index synchronization tracker component.

View Source
const EventBufferSize = 100

EventBufferSize is the buffer size for the event subscription.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexSynchronizationTracker

type IndexSynchronizationTracker struct {
	*component.Base
	// 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) HandleEvent

func (t *IndexSynchronizationTracker) HandleEvent(event busevents.Event)

HandleEvent implements component.EventHandler: it dispatches ResourceSyncCompleteEvent to the sync tracker.

func (*IndexSynchronizationTracker) Start

Start begins monitoring resource synchronization events by running the embedded component.Base event loop until ctx is cancelled.

Jump to

Keyboard shortcuts

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