notify

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package notify provides a pluggable condition notification system that watches the registry KV bucket for component condition transitions and dispatches events via configurable notifiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConditionEvent

type ConditionEvent struct {
	// ComponentType is "agent", "api", or "nats".
	ComponentType string
	// Hostname identifies the component.
	Hostname string
	// Condition is the condition type (e.g., "MemoryPressure").
	Condition string
	// Active is true when the condition fires, false when resolved.
	Active bool
	// Reason describes why the condition triggered or resolved.
	Reason string
	// Timestamp is when the transition occurred.
	Timestamp time.Time
}

ConditionEvent represents a condition state transition on a component.

type LogNotifier

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

LogNotifier logs condition events at INFO level.

func NewLogNotifier

func NewLogNotifier(
	logger *slog.Logger,
) *LogNotifier

NewLogNotifier creates a new LogNotifier that logs condition events using the provided logger.

func (*LogNotifier) Notify

func (n *LogNotifier) Notify(
	_ context.Context,
	event ConditionEvent,
) error

Notify logs the condition event at INFO level and returns nil.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, event ConditionEvent) error
}

Notifier sends notifications when component conditions change.

type Watcher

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

Watcher monitors the registry KV bucket for condition transitions and emits ConditionEvents via the configured Notifier. Active conditions are re-notified after the configured renotify interval.

func NewWatcher

func NewWatcher(
	kv jetstream.KeyValue,
	notifier Notifier,
	logger *slog.Logger,
	renotifyInterval time.Duration,
) *Watcher

NewWatcher creates a new Watcher that monitors registry KV entries and notifies on condition transitions. Active conditions are re-notified after renotifyInterval elapses (0 disables re-notification).

func (*Watcher) Start

func (w *Watcher) Start(
	ctx context.Context,
) error

Start watches the registry KV for changes. Blocks until ctx is cancelled. Returns nil when the context is cancelled, or an error if WatchAll fails.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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