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

tracker

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockTargeter

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

MockTargeter is a mock implementation of Targeter

func NewMockTargeter

func NewMockTargeter(ctrl *gomock.Controller) *MockTargeter

NewMockTargeter creates a new mock instance

func (*MockTargeter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockTargeter) TargetUsage

func (m *MockTargeter) TargetUsage() uint64

TargetUsage mocks base method

type MockTargeterMockRecorder

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

MockTargeterMockRecorder is the mock recorder for MockTargeter

func (*MockTargeterMockRecorder) TargetUsage

func (mr *MockTargeterMockRecorder) TargetUsage() *gomock.Call

TargetUsage indicates an expected call of TargetUsage

type MockTracker

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

MockTracker is a mock implementation of Tracker

func NewMockTracker

func NewMockTracker(ctrl *gomock.Controller) *MockTracker

NewMockTracker creates a new mock instance

func (*MockTracker) EXPECT

func (m *MockTracker) EXPECT() *MockTrackerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockTracker) TimeUntilUsage

func (m *MockTracker) TimeUntilUsage(nodeID ids.NodeID, now time.Time, value float64) time.Duration

TimeUntilUsage mocks base method

func (*MockTracker) TotalUsage

func (m *MockTracker) TotalUsage() float64

TotalUsage mocks base method

func (*MockTracker) Usage

func (m *MockTracker) Usage(nodeID ids.NodeID, now time.Time) float64

Usage mocks base method

type MockTrackerMockRecorder

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

MockTrackerMockRecorder is the mock recorder for MockTracker

func (*MockTrackerMockRecorder) TimeUntilUsage

func (mr *MockTrackerMockRecorder) TimeUntilUsage(nodeID, now, value interface{}) *gomock.Call

TimeUntilUsage indicates an expected call of TimeUntilUsage

func (*MockTrackerMockRecorder) TotalUsage

func (mr *MockTrackerMockRecorder) TotalUsage() *gomock.Call

TotalUsage indicates an expected call of TotalUsage

func (*MockTrackerMockRecorder) Usage

func (mr *MockTrackerMockRecorder) Usage(nodeID, now interface{}) *gomock.Call

Usage indicates an expected call of Usage

type ResourceManager

type ResourceManager interface {
	// CPUUsage returns the current CPU usage percentage
	CPUUsage() float64
	// DiskUsage returns the current disk usage percentage
	DiskUsage() float64
	// Shutdown stops the resource manager
	Shutdown()
}

ResourceManager provides system resource usage metrics

func Manager

func Manager() ResourceManager

Manager creates a ResourceManager using the resource package

type ResourceTracker

type ResourceTracker interface {
	// CPUTracker returns the CPU usage tracker
	CPUTracker() Tracker
	// DiskTracker returns the disk usage tracker
	DiskTracker() Tracker
}

ResourceTracker manages CPU and disk resource tracking

func NewResourceTracker

func NewResourceTracker(
	manager ResourceManager,
	frequency time.Duration,
) (ResourceTracker, error)

NewResourceTracker creates a new ResourceTracker

type Targeter

type Targeter interface {
	// TargetUsage returns the target usage threshold
	TargetUsage() uint64
}

Targeter determines target resource usage thresholds

func NewTargeter

func NewTargeter(config *TargeterConfig) Targeter

NewTargeter creates a new targeter with configurable target usage For disk throttling, VdrAlloc should be in bytes/second (e.g., 1000 GiB) For CPU throttling, VdrAlloc should be the number of CPU cores

type TargeterConfig

type TargeterConfig struct {
	// VdrAlloc is the percentage of resource usage attributed to validators (0-1)
	VdrAlloc float64
	// MaxNonVdrUsage is the max resource usage for non-validators (0-1)
	MaxNonVdrUsage float64
	// MaxNonVdrNodeUsage is the max resource usage per non-validator node (0-1)
	MaxNonVdrNodeUsage float64
}

TargeterConfig defines resource allocation configuration

type Tracker

type Tracker interface {
	// Usage returns the current usage for a given node at the given time
	Usage(nodeID ids.NodeID, now time.Time) float64
	// TimeUntilUsage returns the duration until the usage drops to the given value
	TimeUntilUsage(nodeID ids.NodeID, now time.Time, value float64) time.Duration
	// TotalUsage returns the total usage across all nodes
	TotalUsage() float64
}

Tracker tracks system resource usage caused by each peer

Directories

Path Synopsis
Package trackermock provides mock implementations for testing
Package trackermock provides mock implementations for testing

Jump to

Keyboard shortcuts

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