store

package
v0.0.0-...-df093e9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is exactly that.
	ErrNotFound = errors.New("alert not found")
)

Functions

func IsErrNotFound

func IsErrNotFound(err error) bool

IsErrNotFound checks whether the error is an ErrNotFound.

Types

type AlertStore

type AlertStore struct {
	// contains filtered or unexported fields
}

AlertStore ...

func NewAlertStore

func NewAlertStore(cfg config.Config, recheckInterval time.Duration, persister *FilePersister, logger log.Logger) *AlertStore

NewAlertStore creates a new AlertStore.

func (*AlertStore) AcknowledgeAndSetMultiple

func (a *AlertStore) AcknowledgeAndSetMultiple(extendedAlertList []*client.ExtendedAlert, acknowledgedBy string) error

AcknowledgeAndSetMultiple acknowledges and adds multiple alerts to the AlertStore. If alert already present in AlertStore, additional acknowledgers will be appended.

func (*AlertStore) Count

func (a *AlertStore) Count() int

Count returns the number of items in the AlertStore.

func (*AlertStore) Delete

func (a *AlertStore) Delete(fp model.Fingerprint) error

Delete removes an item from the AlertStore.

func (*AlertStore) Get

Get returns an alert for a given Fingerprint or an error.

func (*AlertStore) GetFromFingerPrintString

func (a *AlertStore) GetFromFingerPrintString(fpString string) (*client.ExtendedAlert, error)

GetFromFingerPrintString returns an alert for a given Fingerprint or an error.

func (*AlertStore) List

func (a *AlertStore) List() []*client.ExtendedAlert

List returns a list of alerts in the AlertStore.

func (*AlertStore) Run

func (a *AlertStore) Run(wg *sync.WaitGroup, stopCh <-chan struct{})

Run runs the AlertStore.

func (*AlertStore) Set

func (a *AlertStore) Set(extendedAlert *client.ExtendedAlert) error

Set adds an alert to the AlertStore.

func (*AlertStore) Snapshot

func (a *AlertStore) Snapshot() error

Snapshot creates a snapshot of the current store

func (*AlertStore) UpdateAlertEndsAt

func (a *AlertStore) UpdateAlertEndsAt(extendedAlert *client.ExtendedAlert) error

UpdateAlertEndsAt updates the EndsAt field of an alert in the AlertStore.

type FilePersister

type FilePersister struct {
	// contains filtered or unexported fields
}

FilePersister is used to save/load an AlertStore to/from a file.

func NewFilePersister

func NewFilePersister(filePath string, logger log.Logger) (*FilePersister, error)

NewFilePersister returns a new FilePersister.

func (*FilePersister) Load

Load attempts to load a store from a file.

func (*FilePersister) Store

func (p *FilePersister) Store(store map[model.Fingerprint]*client.ExtendedAlert) (int64, error)

Store attempts to save a store to a file.

Jump to

Keyboard shortcuts

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