Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultHealthCheckInterval is how often the host should call CheckHealth to // find notification plugin subprocesses that have exited and relaunch them. // Notifications are sparse — a mostly idle agent can go a long time between // them — so waiting for the next Notify to discover a dead plugin would leave // a wide window with no delivery. The interval is short enough to recover // promptly and cheap enough to be free in practice: each check reads an // in-process exit flag per plugin and performs no RPC. DefaultHealthCheckInterval = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NotifierStats ¶ added in v1.5.1
type NotifierStats struct {
// NotifyFailures counts notifications that could not be delivered to a
// plugin, whether because the RPC call failed or because no subprocess was
// running at the time.
NotifyFailures int64
// Restarts counts plugin subprocesses successfully relaunched after an exit.
Restarts int64
// RestartFailures counts relaunch attempts that themselves failed.
RestartFailures int64
}
NotifierStats holds cumulative, process-wide plugin health counters. They are exposed so a silent notification outage — the failure mode this guards against — is observable beyond the per-transition log lines. The zero value means nothing has gone wrong.
type NotifierWrapper ¶
type NotifierWrapper interface {
Kill()
Plugins() []string
Notify(message string) error
// CheckHealth relaunches any plugin subprocess that has exited. It is a no-op
// when every plugin is healthy, when no plugins are configured, or after Kill,
// and is safe to call concurrently with Notify.
CheckHealth()
// Stats returns a snapshot of the cumulative plugin health counters.
Stats() NotifierStats
}
func LoadNotifer ¶
func LoadNotifer( plugins []agent.Plugin, logWriter io.Writer, logger hclog.Logger, ) (NotifierWrapper, error)
LoadNotifer launches every configured notification plugin and returns a wrapper that fans notifications out to all of them. Plugins that fail to launch are reported in the returned error and left out of the set, as before; plugins that launch successfully are supervised from then on — see CheckHealth and Notify, which relaunch a subprocess that later exits or crashes.
Click to show internal directories.
Click to hide internal directories.