tracker

package
v2.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tracker provides utilities for tracking and managing instances within groups. It supports dynamic allocation of instance names and maintains state across namespace boundaries. This package is primarily used by updater to to allocate stable names for scaling operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocateFactory

type AllocateFactory interface {
	// New creates an Allocator for the given namespace and group, with observed instance names
	New(ns, group string, instanceNames ...string) Allocator
}

AllocateFactory creates Allocator to allocate instance names.

type Allocator

type Allocator interface {
	// Allocate returns the instance name for the given index, creating new names as needed
	Allocate(index int) string
}

Allocator provides deterministic allocation of instance names based on index. It ensures that previously allocated names are reused consistently and handles name generation for new instances. Allocate can be called multiple times in one reconciliation. Allocator should be new again in next reconciliation.

type Factory

type Factory interface {
	// Tracker returns a Tracker instance for the specified kind of resource
	Tracker(kind string) Tracker
	// AllocateFactory returns an AllocateFactory instance for the specified kind of resource
	AllocateFactory(kind string) AllocateFactory
}

Factory creates and manages Tracker and AllocateFactory instances for different kinds of resources. Each kind (e.g., "tidb", "tikv", "pd") maintains its own separate tracking state.

func New

func New() Factory

New creates a new Factory instance for managing trackers across different resource kinds.

type NewNameFunc

type NewNameFunc func() string

NewNameFunc is a function type that generates new instance names.

type Tracker

type Tracker interface {
	// Track registers an instance with the given namespace, name, and group
	Track(ns, name, group string)
	// Untrack removes an instance from tracking when it's deleted
	Untrack(ns, name string)
}

Tracker tracks changes of instances within groups across namespaces. It maintains the relationship between instance and their groups, allowing for proper cleanup when instances are deleted.

Jump to

Keyboard shortcuts

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