Documentation ¶
Index ¶
Constants ¶
const ( //ServiceStarted is a code for starting a particular service ServiceStarted = 1 //ServiceRunning is a code for running instance a particular service ServiceRunning = 2 //ServiceStopped is a code for stopping a particular service ServiceStopped = 3 )
Variables ¶
var IntervalValue = 5 * time.Minute
IntervalValue is a default value for heartbeat interval
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is a structure for heartbeat
func NewHeartbeatConfig ¶
NewHeartbeatConfig is a constructor to return the object of heartbeatConfig structure
func (*Config) CreateEnabled ¶
func (config *Config) CreateEnabled(doneChan chan struct{}, serviceName string) (*StatusBeater, error)
CreateEnabled will create all miscellaneous components
type Heartbeat ¶
type Heartbeat struct { // Service name ServiceName string `json:"service_name"` // Current version of the service ServiceVersion string `json:"service_version"` Time timestamp.Timestamp `json:"time"` Status Status `json:"status"` }
Heartbeat is a structure for heartbeat
type IntervalFunc ¶
IntervalFunc is a function that can trigger a timing event based on a duration
type StatusBeater ¶
type StatusBeater struct { Name string Version string IntervalFunc IntervalFunc // contains filtered or unexported fields }
StatusBeater reports simple service information
func NewStatusBeater ¶
func NewStatusBeater(serviceName string, interval time.Duration, doneChan chan struct{}) *StatusBeater
NewStatusBeater will return a new StatusBeater with the provided base information
func NewStatusBeaterWithFunc ¶
func NewStatusBeaterWithFunc(serviceName string, intervalFunc IntervalFunc, doneChan chan struct{}) *StatusBeater
NewStatusBeaterWithFunc returns a new StatusBeater that uses the provided func as a trigger for sending beats
func (*StatusBeater) Beat ¶
func (sb *StatusBeater) Beat(status int64, description string, publish func(event beat.Event))
Beat will send a beat containing simple service status information
func (*StatusBeater) PublishEvent ¶
func (sb *StatusBeater) PublishEvent(logData []byte, publish func(event beat.Event))
PublishEvent will publish passed Log
func (*StatusBeater) Start ¶
func (sb *StatusBeater) Start(stopChan chan struct{}, publish func(event beat.Event))
Start will begin reporting heartbeats through the beats