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).