monitor

package
v1.5.1-testnet Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Health check configuration
	Health health.CounterConfig

	// Maximum allowable duration for sync height to remain unchanged.
	MaxStalledDuration time.Duration `default:"5m"`
	// Maximum allowed lag in height between the latest chain height and the sync height.
	MaxAllowedLag uint64 `default:"200"`
}

Config holds the configuration parameters for the sync monitor.

func NewConfig

func NewConfig() (conf Config)

NewConfig returns a new Config with default values.

type HealthObserver

type HealthObserver interface {
	OnStateChange(state HealthState, details ...string)
}

type HealthState

type HealthState string
const (
	Healthy     HealthState = "Healthy"
	Unhealthy   HealthState = "Unhealthy"
	Unrecovered HealthState = "Unrecovered"
)

type Monitor

type Monitor struct {
	Config
	// contains filtered or unexported fields
}

Monitor periodically checks sync height growth.

func NewMonitor

func NewMonitor(cfg Config, latestHeightFunc func() (uint64, error)) *Monitor

func (*Monitor) SetObserver

func (m *Monitor) SetObserver(observer HealthObserver)

func (*Monitor) Start

func (m *Monitor) Start(ctx context.Context)

Start begins the monitoring process by checking sync status periodically.

func (*Monitor) Stop

func (m *Monitor) Stop()

Stop halts the monitoring process.

func (*Monitor) Update

func (m *Monitor) Update(newHeight uint64)

Update updates the current sync height.

Jump to

Keyboard shortcuts

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