Documentation ¶
Overview ¶
Package statuscheck defines the status report API for other CN-Infra plugins and implements the health status aggregator/exporter. Health status is collected from other plugins through the plugin status report API and aggregated and exported/exposed via ETCD or a REST API.
The API provides only two functions, one for registering the plugin for status change reporting and one for reporting status changes.
To register a plugin for providing status reports, use Register() function:
statuscheck.Register(PluginID, probe)
If probe is not nil, statuscheck will periodically probe the plugin state through the provided function. Otherwise, it is expected that the plugin itself will report state updates through ReportStateChange(), e.g.:
statuscheck.ReportStateChange(PluginID, statuscheck.OK, nil)
The default status of a plugin after registering is Init.
Index ¶
- type AgentStatusReader
- type Deps
- type Plugin
- func (p *Plugin) AfterInit() error
- func (p *Plugin) Close() error
- func (p *Plugin) GetAgentStatus() status.AgentStatus
- func (p *Plugin) GetAllPluginStatus() map[string]*status.PluginStatus
- func (p *Plugin) GetPluginStatusMap() pluginstatusmap.PluginStatusIdxMap
- func (p *Plugin) Init() error
- func (p *Plugin) Register(pluginName core.PluginName, probe PluginStateProbe)
- func (p *Plugin) ReportStateChange(pluginName core.PluginName, state PluginState, lastError error)
- type PluginState
- type PluginStateProbe
- type PluginStatusReader
- type PluginStatusWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentStatusReader ¶
type AgentStatusReader interface { // GetAgentStatus returns the current global operational state of the agent. GetAgentStatus() status.AgentStatus }
AgentStatusReader allows to lookup agent status by other plugins.
type Deps ¶
type Deps struct { Log logging.PluginLogger // inject PluginName core.PluginName // inject Transport datasync.KeyProtoValWriter // inject (optional) }
Deps lists the dependencies of statuscheck plugin.
type Plugin ¶
type Plugin struct { Deps // contains filtered or unexported fields }
Plugin struct holds all plugin-related data.
func (*Plugin) AfterInit ¶
AfterInit starts go routines for periodic probing and periodic updates. Initial state data are published via the injected transport.
func (*Plugin) GetAgentStatus ¶
func (p *Plugin) GetAgentStatus() status.AgentStatus
GetAgentStatus return current global operational state of the agent.
func (*Plugin) GetAllPluginStatus ¶ added in v1.0.4
func (p *Plugin) GetAllPluginStatus() map[string]*status.PluginStatus
GetAllPluginStatus returns a map containing pluginname and its status, for all plugins
func (*Plugin) GetPluginStatusMap ¶ added in v1.0.4
func (p *Plugin) GetPluginStatusMap() pluginstatusmap.PluginStatusIdxMap
GetPluginStatusMap returns a read-only copy of a map containing pluginname and its status, for all plugins
func (*Plugin) Register ¶
func (p *Plugin) Register(pluginName core.PluginName, probe PluginStateProbe)
Register a plugin for status change reporting.
func (*Plugin) ReportStateChange ¶
func (p *Plugin) ReportStateChange(pluginName core.PluginName, state PluginState, lastError error)
ReportStateChange can be used to report a change in the status of a previously registered plugin.
type PluginState ¶
type PluginState string
PluginState is a data type used to describe the current operational state of a plugin.
const ( // Init state means that the initialization of the plugin is in progress. Init PluginState = "init" // OK state means that the plugin is healthy. OK PluginState = "ok" // Error state means that some error has occurred in the plugin. Error PluginState = "error" )
type PluginStateProbe ¶
type PluginStateProbe func() (PluginState, error)
PluginStateProbe defines parameters of a function used for plugin state probing, referred to as "probe".
type PluginStatusReader ¶ added in v1.0.4
type PluginStatusReader interface { //TODO combine AgentStatusReader and PluginStatusReader in one interface GetAllPluginStatus() map[string]*status.PluginStatus GetPluginStatusMap() pluginstatusmap.PluginStatusIdxMap }
PluginStatusReader allows to retrieve a map containing status of all plugins.
type PluginStatusWriter ¶
type PluginStatusWriter interface { // Register registers a plugin for status change reporting. // If <probe> is not nil, Statuscheck will periodically probe the plugin // state through the provided function. Otherwise, it is expected that the // plugin itself will report state updates through ReportStateChange(). Register(pluginName core.PluginName, probe PluginStateProbe) // ReportStateChange can be used to report a change in the status // of a previously registered plugin. It is not a bug, however, to report // the same status in consecutive calls. Statuscheck is smart enough // to detect an actual status change and propagate only updates to remote // clients. ReportStateChange(pluginName core.PluginName, state PluginState, lastError error) }
PluginStatusWriter allows to register & write plugin status by other plugins
Directories ¶
Path | Synopsis |
---|---|
model
|
|
status
Package status is a generated protocol buffer package.
|
Package status is a generated protocol buffer package. |
Package pluginstatusmap implements specialization of idxmap used to store plugin status by plugin name.
|
Package pluginstatusmap implements specialization of idxmap used to store plugin status by plugin name. |