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 ¶
const ConditionComponentUnreachable types.ConditionType = "ComponentUnreachable"
ConditionComponentUnreachable is the condition of a component whose heartbeat expired. Only the notifier sends it: no component reports it, so it is not one of types.ConditionType values.
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 types.ConditionType
// 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 Registry ¶ added in v0.3.0
type Registry interface {
KVWatch(
ctx context.Context,
bucket string,
pattern string,
opts ...jetstream.WatchOpt,
) (<-chan jetstream.KeyValueEntry, error)
}
Registry watches the registry KV bucket. A *natsclient.Client is one.
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 Registry, bucket string, 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).