Help us shape the future of Go! Take the 2026 Go Developer Survey

uptime

package
v1.13.10 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculator

type Calculator interface {
	CalculateUptime(nodeID ids.NodeID) (time.Duration, time.Time, error)
	CalculateUptimePercent(nodeID ids.NodeID) (float64, error)
	// CalculateUptimePercentFrom expects [startTime] to be truncated (floored) to the nearest second
	CalculateUptimePercentFrom(nodeID ids.NodeID, startTime time.Time) (float64, error)
}
var NoOpCalculator Calculator = noOpCalculator{}

type LockedCalculator added in v0.15.6

type LockedCalculator interface {
	Calculator

	SetCalculator(isBootstrapped *utils.Atomic[bool], lock sync.Locker, newC Calculator)
}

func NewLockedCalculator added in v0.15.6

func NewLockedCalculator() LockedCalculator

type Manager

type Manager interface {
	Tracker
	Calculator
}

func NewManager added in v0.15.6

func NewManager(state State, clk *mockable.Clock) Manager

type State

type State interface {
	// GetUptime returns [upDuration] and [lastUpdated] of [nodeID]
	// Returns [database.ErrNotFound] if [nodeID] isn't currently a validator.
	GetUptime(
		nodeID ids.NodeID,
	) (upDuration time.Duration, lastUpdated time.Time, err error)

	// SetUptime updates [upDuration] and [lastUpdated] of [nodeID]
	// Returns [database.ErrNotFound] if [nodeID] isn't currently a validator
	// Invariant: expects [lastUpdated] to be truncated (floored) to the nearest
	//            second.
	SetUptime(
		nodeID ids.NodeID,
		upDuration time.Duration,
		lastUpdated time.Time,
	) error

	// GetStartTime returns the time that [nodeID] started validating.
	// Returns [database.ErrNotFound] if [nodeID] isn't currently a validator.
	GetStartTime(
		nodeID ids.NodeID,
	) (startTime time.Time, err error)
}

type TestState added in v0.15.6

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

func NewTestState added in v0.15.6

func NewTestState() *TestState

func (*TestState) AddNode added in v0.15.6

func (s *TestState) AddNode(nodeID ids.NodeID, startTime time.Time)

func (*TestState) GetStartTime added in v0.15.6

func (s *TestState) GetStartTime(nodeID ids.NodeID) (time.Time, error)

func (*TestState) GetUptime added in v0.15.6

func (s *TestState) GetUptime(nodeID ids.NodeID) (time.Duration, time.Time, error)

func (*TestState) SetUptime added in v0.15.6

func (s *TestState) SetUptime(nodeID ids.NodeID, upDuration time.Duration, lastUpdated time.Time) error

type Tracker added in v0.15.6

type Tracker interface {
	StartTracking(nodeIDs []ids.NodeID) error
	StopTracking(nodeIDs []ids.NodeID) error
	StartedTracking() bool

	Connect(nodeID ids.NodeID) error
	IsConnected(nodeID ids.NodeID) bool
	Disconnect(nodeID ids.NodeID) error
}

Directories

Path Synopsis
Package uptimemock is a generated GoMock package.
Package uptimemock is a generated GoMock package.

Jump to

Keyboard shortcuts

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