Documentation
¶
Overview ¶
Package notify is Console's alerting seam. A Notifier delivers a core.Event to an external sink (Slack, a webhook, email); the Dispatcher fans an event out to every registered Notifier. The flag and status engines emit events through a Dispatcher, so monitoring can actually reach a human.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher fans events out to its Notifiers, best-effort: a slow or failing sink is bounded by a timeout and logged, and never fails the operation that produced the event. Its Emit method matches the engines' emitter hook.
func NewDispatcher ¶
func NewDispatcher(notifiers ...Notifier) *Dispatcher
NewDispatcher builds a Dispatcher with the given notifiers.
func (*Dispatcher) Emit ¶
func (d *Dispatcher) Emit(ev core.Event)
Emit delivers ev to every notifier synchronously, bounding each with the dispatcher timeout against a fresh background context (so a notification outlives the request that triggered it). Errors are logged, never returned.
func (*Dispatcher) Len ¶
func (d *Dispatcher) Len() int
Len reports how many notifiers are registered.
type Notifier ¶
type Notifier interface {
// Name identifies the sink, e.g. "slack".
Name() string
// Notify delivers ev. A returned error is logged, not propagated to the
// triggering operation.
Notify(ctx context.Context, ev core.Event) error
}
Notifier delivers an event to one destination. Implementations should be safe for concurrent use and return promptly; the Dispatcher bounds each call with a timeout but calls them on the path that triggered the event.