Documentation
¶
Overview ¶
Package nflog implements a garbage-collected and snapshottable append-only log of active/resolved notifications. Each log entry stores the active/resolved state, the notified receiver, and a hash digest of the notification's identifying contents. The log can be queried along different parameters.
Index ¶
- Variables
- type Log
- func (l *Log) GC() (int, error)
- func (l *Log) Log(r *pb.Receiver, gkey string, firingAlerts, resolvedAlerts []uint64, ...) error
- func (l *Log) Maintenance(interval time.Duration, snapf string, stopc <-chan struct{}, ...)
- func (l *Log) MarshalBinary() ([]byte, error)
- func (l *Log) Merge(b []byte) error
- func (l *Log) Query(params ...QueryParam) ([]*pb.Entry, error)
- func (l *Log) SetBroadcast(f func([]byte))
- func (l *Log) Snapshot(w io.Writer) (int64, error)
- type MaintenanceFunc
- type Options
- type QueryParam
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidState = errors.New("invalid state")
ErrInvalidState is returned if the state isn't valid.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned for empty query results.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log holds the notification log state for alerts that have been notified.
func New ¶
New creates a new notification log based on the provided options. The snapshot is loaded into the Log if it is set.
func (*Log) Maintenance ¶
func (l *Log) Maintenance(interval time.Duration, snapf string, stopc <-chan struct{}, override MaintenanceFunc)
Maintenance garbage collects the notification log state at the given interval. If the snapshot file is set, a snapshot is written to it afterwards. Terminates on receiving from stopc. If not nil, the last argument is an override for what to do as part of the maintenance - for advanced usage.
func (*Log) MarshalBinary ¶
MarshalBinary serializes all contents of the notification log.
func (*Log) Merge ¶
Merge merges notification log state received from the cluster with the local state.
func (*Log) Query ¶
func (l *Log) Query(params ...QueryParam) ([]*pb.Entry, error)
Query implements the Log interface.
func (*Log) SetBroadcast ¶
SetBroadcast sets a broadcast callback that will be invoked with serialized state on updates.
type MaintenanceFunc ¶
MaintenanceFunc represents the function to run as part of the periodic maintenance for the nflog. It returns the size of the snapshot taken or an error if it failed.
type Options ¶
type Options struct { SnapshotReader io.Reader SnapshotFile string Retention time.Duration Logger log.Logger Metrics prometheus.Registerer }
Options configures a new Log implementation.
type QueryParam ¶
type QueryParam func(*query) error
QueryParam is a function that modifies a query to incorporate a set of parameters. Returns an error for invalid or conflicting parameters.
func QGroupKey ¶
func QGroupKey(gk string) QueryParam
QGroupKey adds a group key as querying argument.
func QReceiver ¶
func QReceiver(r *pb.Receiver) QueryParam
QReceiver adds a receiver parameter to a query.