alerting

package
v0.0.0-...-1a3a2fa Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScoreThreshold = -1
	CountThreshold = 1.0

	IgnoreFailureCountThreshold = 3

	NotificationSubject = "Stillbox Alert"
	DefaultRenotify     = 30 * time.Minute
)

Variables

This section is empty.

Functions

func OffsetClock

func OffsetClock(d time.Duration) offsetClock

OffsetClock returns a clock whose Now() method returns the specified offset from the current time.

Types

type AlertOption

type AlertOption func(*alerter)

func WithAlertStore

func WithAlertStore(st alertstore.Store) AlertOption

func WithClock

func WithClock(clock timeseries.Clock) AlertOption

WithClock makes the alerter use a simulated clock.

func WithMetrics

func WithMetrics(met metrics.Metrics) AlertOption

func WithNotifier

func WithNotifier(n notify.Notifier) AlertOption

WithNotifier sets the notifier

type Alerter

type Alerter interface {
	sinks.Sink

	Enabled() bool
	Go(context.Context)
	HUP(*config.Config)
	// contains filtered or unexported methods
}

func New

func New(cfg config.Alerting, tgCache tgstore.Store, opts ...AlertOption) Alerter

New creates a new Alerter using the provided configuration.

type Simulation

type Simulation struct {
	// normal Alerting config
	config.Alerting

	// ScoreStart is the time when scoring begins
	ScoreStart jsontypes.Time `json:"scoreStart" yaml:"scoreStart" form:"scoreStart"`
	// ScoreEnd is the time when the score simulator ends. Left blank, it defaults to time.Now()
	ScoreEnd jsontypes.Time `json:"scoreEnd" yaml:"scoreEnd" form:"scoreEnd"`

	// SimInterval is the interval at which the scorer will be called
	SimInterval jsontypes.Duration `json:"simInterval" yaml:"simInterval" form:"simInterval"`
	// contains filtered or unexported fields
}

A Simulation simulates what happens to the alerter during a specified time period using past data from the database.

func (Simulation) Call

func (as Simulation) Call(ctx context.Context, call *calls.Call) error

func (Simulation) Enabled

func (Simulation) Enabled() bool

func (Simulation) Go

func (as Simulation) Go(ctx context.Context)

Go is the alerting loop. It does not start a goroutine.

func (Simulation) HUP

func (as Simulation) HUP(cfg *config.Config)

func (Simulation) Name

func (a Simulation) Name() string

func (Simulation) PrivateRoutes

func (as Simulation) PrivateRoutes(r chi.Router)

func (*Simulation) Simulate

func (s *Simulation) Simulate(ctx context.Context) (trending.Scores[talkgroups.ID], error)

Simulate begins the simulation using the DB handle from ctx. It returns final scores.

func (Simulation) SinkType

func (as Simulation) SinkType() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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