Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor struct {
ID string // unique heartbeat identifier
Interval time.Duration // expected interval between pings
Description string // human‐friendly description of this heartbeat
Grace time.Duration // grace period before triggering an alert
Receivers []string // list of receiver IDs to notify upon alerts
LastBump time.Time // timestamp of the last received heartbeat
State common.HeartbeatState // current state (idle, active, grace, missing, etc.)
// contains filtered or unexported fields
}
Actor handles a single heartbeat’s lifecycle.
func NewActorFromConfig ¶ added in v0.14.0
func NewActorFromConfig(cfg ActorConfig) *Actor
NewActorFromConfig creates a new heartbeat actor.
type ActorConfig ¶ added in v0.14.0
type ActorConfig struct {
Ctx context.Context // context for cancellation and lifecycle control
ID string // unique heartbeat identifier
Description string // human-readable description of the heartbeat
Interval time.Duration // expected interval between heartbeat pings
Grace time.Duration // grace period after a missed ping before triggering an alert
Receivers []string // list of receiver IDs to notify on failure
Logger *slog.Logger // logger scoped to this actor
History history.Store // store to persist heartbeat and notification events
DispatchCh chan<- notifier.NotificationData // channel to send notifications through the dispatcher
}
ActorConfig holds all parameters required to construct a heartbeat Actor.
type HeartbeatConfig ¶
type HeartbeatConfig struct {
ID string `json:"id"`
Description string `json:"description"`
Interval time.Duration `json:"interval"`
Grace time.Duration `json:"grace"`
Receivers []string `json:"receivers"`
}
HeartbeatConfig contains heartbeat settings.
type HeartbeatConfigMap ¶
type HeartbeatConfigMap map[string]HeartbeatConfig
HeartbeatConfigMap injects the map key as the ID field into each HeartbeatConfig during YAML unmarshalling.
func (*HeartbeatConfigMap) UnmarshalYAML ¶
func (hcm *HeartbeatConfigMap) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML parses the map and assigns each key as the ID field of its HeartbeatConfig.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager routes HTTP pings to Actors.
func NewManagerFromHeartbeatMap ¶ added in v0.14.0
func NewManagerFromHeartbeatMap( ctx context.Context, heartbeatConfigs HeartbeatConfigMap, dispatchCh chan<- notifier.NotificationData, hist history.Store, logger *slog.Logger, ) *Manager
NewManagerFromHeartbeatMap creates a Manager from heartbeat config and launches all actors.
func (*Manager) HandleFail ¶
HandleFail marks the Actor failed or logs unknown ID.
func (*Manager) HandleReceive ¶
HandleReceive pings the Actor or logs unknown ID.
func (*Manager) HandleTest ¶ added in v0.14.0
HandleTest sends only a notification to the Actor.