Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLimited = errors.New("alert limited")

ErrLimited is returned if a Store has reached the per-alert limit.

View Source
var ErrNotFound = errors.New("alert not found")

ErrNotFound is returned if a Store cannot find the Alert.

Functions

This section is empty.

Types

type Alerts

type Alerts struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Alerts provides lock-coordinated to an in-memory map of alerts, keyed by their fingerprint. Resolved alerts are removed from the map based on gcInterval. An optional callback can be set which receives a slice of all resolved alerts that have been removed.

func NewAlerts

func NewAlerts() *Alerts

NewAlerts returns a new Alerts struct.

func (*Alerts) DeleteIfNotModified added in v0.28.0

func (a *Alerts) DeleteIfNotModified(alerts types.AlertSlice) error

DeleteIfNotModified deletes the slice of Alerts from the store if not modified.

func (*Alerts) Empty added in v0.17.0

func (a *Alerts) Empty() bool

Empty returns true if the store is empty.

func (*Alerts) GC added in v0.28.0

func (a *Alerts) GC() []types.Alert

GC deletes resolved alerts and returns them.

func (*Alerts) Get

func (a *Alerts) Get(fp model.Fingerprint) (*types.Alert, error)

Get returns the Alert with the matching fingerprint, or an error if it is not found.

func (*Alerts) Len added in v0.30.0

func (a *Alerts) Len() int

Len returns the number of alerts in the store.

func (*Alerts) List

func (a *Alerts) List() []*types.Alert

List returns a slice of Alerts currently held in memory.

func (*Alerts) Run

func (a *Alerts) Run(ctx context.Context, interval time.Duration)

Run starts the GC loop. The interval must be greater than zero; if not, the function will panic.

func (*Alerts) Set

func (a *Alerts) Set(alert *types.Alert) error

Set unconditionally sets the alert in memory.

func (*Alerts) SetGCCallback

func (a *Alerts) SetGCCallback(cb func([]types.Alert))

SetGCCallback sets a GC callback to be executed after each GC.

func (*Alerts) WithPerAlertLimit added in v0.31.0

func (a *Alerts) WithPerAlertLimit(lim int) *Alerts

WithPerAlertLimit sets the per-alert limit for the Alerts struct.

Jump to

Keyboard shortcuts

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