types

package
v0.0.0-...-baf6593 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DaemonStartupGracePeriod is the amount of time to wait for before a daemon is expected to start querying
	// the daemon server. This is used to ensure that spurious panics aren't produced due to the daemons waiting for
	// the cosmos grpc service to start. If cli tests are failing due to panics because it is taking the network
	// a long time to start the protocol, it's possible this value could be increased.
	DaemonStartupGracePeriod = 60 * time.Second

	// MaximumLoopDelayMultiple defines the maximum acceptable update delay for a daemon as a multiple of the
	// daemon's loop delay. This is set to 8 to have generous headroom to ignore errors from the liquidations daemon,
	// which we have sometimes seen to take up to ~10s to respond.
	MaximumLoopDelayMultiple = 8

	LiquidationsDaemonServiceName = "liquidations-daemon"
	PricefeedDaemonServiceName    = "pricefeed-daemon"
	BridgeDaemonServiceName       = "bridge-daemon"
	MetricsDaemonServiceName      = "metrics-daemon"
)
View Source
const (
	// HealthCheckPollFrequency is the frequency at which the health-checkable service is polled.
	HealthCheckPollFrequency = 5 * time.Second

	// HealthMonitorLogModuleName is the module name used for logging within the health monitor.
	HealthMonitorLogModuleName = "daemon-health-monitor"
)

Variables

This section is empty.

Functions

func LogErrorServiceNotResponding

func LogErrorServiceNotResponding(hc types.HealthCheckable, logger log.Logger) func(error)

LogErrorServiceNotResponding returns a function that logs an error indicating that the specified service is not responding. This is ideal for creating a callback function when registering a health-checkable service.

func PanicServiceNotResponding

func PanicServiceNotResponding(hc types.HealthCheckable) func(error)

PanicServiceNotResponding returns a function that panics with a message indicating that the specified daemon service is not responding. This is ideal for creating a callback function when registering a daemon service.

func StartNewHealthChecker

func StartNewHealthChecker(
	healthCheckable types.HealthCheckable,
	pollFrequency time.Duration,
	unhealthyCallback func(error),
	timeProvider libtime.TimeProvider,
	maxUnhealthyDuration time.Duration,
	startupGracePeriod time.Duration,
	logger log.Logger,
) *healthChecker

StartNewHealthChecker creates and starts a new health checker for a health-checkable service.

Types

type HealthMonitor

type HealthMonitor struct {
	// contains filtered or unexported fields
}

HealthMonitor monitors the health of daemon services, which implement the HealthCheckable interface. If a registered health-checkable service sustains an unhealthy state for the maximum acceptable unhealthy duration, the monitor will execute a callback function.

func NewHealthMonitor

func NewHealthMonitor(
	startupGracePeriod time.Duration,
	pollingFrequency time.Duration,
	logger log.Logger,
	enablePanics bool,
) *HealthMonitor

NewHealthMonitor creates a new health monitor.

func (*HealthMonitor) DisableForTesting

func (hm *HealthMonitor) DisableForTesting()

func (*HealthMonitor) RegisterService

func (hm *HealthMonitor) RegisterService(
	hc types.HealthCheckable,
	maxDaemonUnhealthyDuration time.Duration,
) error

RegisterService registers a new health-checkable service with the health check monitor. If the service is unhealthy every time it is polled for a duration greater than or equal to the maximum acceptable unhealthy duration, the monitor will panic or log an error, depending on the app configuration via the `panic-on-daemon-failure-enabled` flag. This method is synchronized. It returns an error if the service was already registered or the monitor has already been stopped. If the monitor has been stopped, this method will proactively stop the health-checkable service before returning.

func (*HealthMonitor) RegisterServiceWithCallback

func (hm *HealthMonitor) RegisterServiceWithCallback(
	hc types.HealthCheckable,
	maxUnhealthyDuration time.Duration,
	callback func(error),
) error

RegisterServiceWithCallback registers a HealthCheckable with the health monitor. If the service stays unhealthy every time it is polled during the maximum acceptable unhealthy duration, the monitor will execute the callback function. This method is synchronized. The method returns an error if the service was already registered or the monitor has already been stopped. If the monitor has been stopped, this method will proactively stop the health-checkable service before returning.

func (*HealthMonitor) Stop

func (hm *HealthMonitor) Stop()

Stop stops the update frequency monitor. This method is synchronized.

type Stoppable

type Stoppable interface {
	Stop()
}

Stoppable is an interface for a service that can be stopped. This is used to stop services registered with the health monitor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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