Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Changelog ¶
type Changelog[T comparable] struct { // contains filtered or unexported fields }
Changelog manages a list of changes (entries) for a single type. When instantiating a Changelog struct, one must supply the maximum amount of changes that can be tracked.
ATTENTION: You should use Changelog within a struct and provide methods to access it, coordinating access through your struct mutexes. DO NOT EXPOSE the Changelog object directly to the outside world as it is not thread-safe.
func NewChangelog ¶
func NewChangelog[T comparable](maxEntries MaxEntries) *Changelog[T]
NewChangelog initializes a new `Changelog` with the specified maximum number of entries.
func (*Changelog[T]) Get ¶
Get retrieves the value of the entry at or before the given timestamp. If no matching entry is found, it returns the default value for the entry type.
func (*Changelog[T]) GetAll ¶
func (c *Changelog[T]) GetAll() []T
GetAll retrieves all values, from the newest to the oldest.
func (*Changelog[T]) GetCurrent ¶
func (c *Changelog[T]) GetCurrent() T
GetCurrent retrieves the most recent value. If no entry is found, it returns the default value for the entry type.
type MaxEntries ¶ added in v0.23.0
type MaxEntries uint8
MaxEntries represents the maximum number of changes that can be tracked.