heartbeat

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var IntervalValue = 5 * time.Minute

IntervalValue is a default value for heartbeat interval

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval time.Duration
	Disabled bool
}

Config is a structure for heartbeat

func NewHeartbeatConfig

func NewHeartbeatConfig(interval time.Duration, disabled bool) *Config

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

type IntervalFunc func() <-chan time.Time

IntervalFunc is a function that can trigger a timing event based on a duration

type Status

type Status struct {
	Code        int64  `json:"code"`
	Description string `json:"description"`
}

Status is used for status of heartbeat1

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL