Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tracker ¶
type Tracker[T any] struct { // contains filtered or unexported fields }
Tracker is a concurrency-safe map wrapper for tracking live objects like containers or services.
It uses a sync.RWMutex to guard access to its internal map. The zero value of tracker is ready to use; calling Set() will lazily initialize the internal map if needed.
The type parameter T can be either a value type (e.g. int, struct) or a pointer type (e.g. *ContainerConfig). Use pointers if T contains fields that should not be copied (for example tombs, mutexes, or loggers).
func NewTracker ¶
NewTracker creates and initializes a new tracker for type T.
While the zero value of Tracker is ready to use, using the constructor is recommended in case future versions require explicit initialization.
func (*Tracker[T]) Clear ¶
Clear removes all tracked items and returns a snapshot of the previous contents.
The returned map is a shallow copy of the internal state at the time of the call, so further modifications to it do not affect the tracker.
func (*Tracker[T]) Get ¶
Get returns the item stored under the given id, along with a boolean indicating whether it was found.
func (*Tracker[T]) GetAll ¶
GetAll returns a snapshot copy of all items currently in the tracker.
The returned map is a shallow copy: modifying it will not affect the underlying tracker contents. Safe for concurrent use.