Documentation
¶
Index ¶
- Constants
- func StateSyncChunkMetricsExist(ctx context.Context, metricsURL string) (bool, error)
- type Client
- func (c *Client) GetCPUStats(ctx context.Context, since time.Duration) (float64, error)
- func (c *Client) GetDataSize(ctx context.Context) (int64, error)
- func (c *Client) GetLatestHeight(ctx context.Context) (int64, error)
- func (c *Client) GetMemoryStats(ctx context.Context, since time.Duration) (uint64, error)
- func (c *Client) IsStateSyncing(ctx context.Context) (bool, error)
- func (c *Client) ListSnapshots(ctx context.Context) ([]int64, error)
- func (c *Client) RequiresUpgrade(ctx context.Context) (bool, error)
- func (c *Client) ShutdownNodeUtilsServer(ctx context.Context) error
- type MockStats
- func (m *MockStats) GetCPU() float64
- func (m *MockStats) GetMemory() uint64
- func (m *MockStats) SetCPU(cores float64)
- func (m *MockStats) SetCPUMillicores(millicores int64)
- func (m *MockStats) SetMemory(bytes uint64)
- func (m *MockStats) SetMemoryGiB(gib float64)
- func (m *MockStats) SetMemoryMiB(mib int64)
- type NodeUtils
- type Option
- func CreateFifo(create bool) Option
- func WithBlockThreshold(n time.Duration) Option
- func WithDataPath(path string) Option
- func WithHaltHeight(height int64) Option
- func WithHost(s string) Option
- func WithMockMode(enable bool) Option
- func WithPort(v int) Option
- func WithTmkmsProxy(enable bool) Option
- func WithTraceStore(path string) Option
- func WithUpgradesConfig(path string) Option
- type Options
- type ProcessStats
- type StatsClient
- type Upgrade
- type UpgradeChecker
- type UpgradeSource
- type UpgradesConfig
Constants ¶
const ( // DefaultPort is the default port for the node-utils HTTP server. DefaultPort = 8000 // DefaultHost is the default host for the node-utils HTTP server. DefaultHost = "0.0.0.0" // DefaultDataPath is the default path to the node's data directory. DefaultDataPath = "/home/app/data" // DefaultUpgradesConfig is the default path to the upgrades configuration file. DefaultUpgradesConfig = "/config/upgrades.json" // DefaultTraceStore is the default path to the trace store FIFO. DefaultTraceStore = "/trace/trace.fifo" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides methods to interact with the node-utils HTTP server.
func NewClient ¶
NewClient creates a new node-utils client for the given host. The host should be a hostname or IP address without scheme or port.
func (*Client) GetCPUStats ¶
GetCPUStats returns the CPU usage percentage. If since is greater than 0, it returns the average over that duration.
func (*Client) GetDataSize ¶
GetDataSize returns the current size of the node's data directory in bytes.
func (*Client) GetLatestHeight ¶
GetLatestHeight returns the latest block height from the blockchain node.
func (*Client) GetMemoryStats ¶
GetMemoryStats returns the memory usage in bytes. If since is greater than 0, it returns the average over that duration.
func (*Client) IsStateSyncing ¶
IsStateSyncing returns true if the node is currently performing state-sync.
func (*Client) ListSnapshots ¶
ListSnapshots returns a list of available snapshot heights.
func (*Client) RequiresUpgrade ¶
RequiresUpgrade checks if the node requires an upgrade. Returns true if an upgrade is required, false otherwise.
type MockStats ¶ added in v2.2.0
type MockStats struct {
// contains filtered or unexported fields
}
MockStats holds the mock CPU and memory values.
func NewMockStats ¶ added in v2.2.0
func NewMockStats() *MockStats
NewMockStats creates a new MockStats with default values. Default memory is 300Mi - chosen to be in the "safe zone" (40-80% usage) for typical test initial values, avoiding immediate VPA triggers.
func (*MockStats) SetCPUMillicores ¶ added in v2.2.0
SetCPUMillicores sets the mock CPU usage in millicores.
func (*MockStats) SetMemoryGiB ¶ added in v2.2.0
SetMemoryGiB sets the mock memory usage in GiB.
func (*MockStats) SetMemoryMiB ¶ added in v2.2.0
SetMemoryMiB sets the mock memory usage in MiB.
type Option ¶
type Option func(*Options)
func CreateFifo ¶
func WithBlockThreshold ¶
func WithDataPath ¶
func WithHaltHeight ¶
func WithMockMode ¶ added in v2.2.0
func WithTmkmsProxy ¶
func WithTraceStore ¶
func WithUpgradesConfig ¶
type ProcessStats ¶
type ProcessStats struct {
CPUTimeSec float64 `json:"cpu_time_sec"` // total CPU time in seconds
MemoryRSS uint64 `json:"memory_rss_bytes"` // resident memory usage
}
func GetProcessStats ¶
func GetProcessStats(proc *process.Process) (*ProcessStats, error)
GetProcessStats extracts CPU + memory usage from a gopsutil Process
type StatsClient ¶ added in v2.2.0
type StatsClient interface {
GetCPUStats(ctx context.Context, since time.Duration) (float64, error)
GetMemoryStats(ctx context.Context, since time.Duration) (uint64, error)
}
StatsClient defines the interface for getting node resource stats. This interface is primarily used for VPA (Vertical Pod Autoscaler) functionality and can be mocked in tests.
type Upgrade ¶
type Upgrade struct {
Height int64 `json:"height"`
Status string `json:"status"`
Image string `json:"image"`
Source UpgradeSource `json:"source"`
}
type UpgradeChecker ¶
type UpgradeChecker struct {
// contains filtered or unexported fields
}
func NewUpgradeChecker ¶
func NewUpgradeChecker(configFile string) (*UpgradeChecker, error)
func (*UpgradeChecker) GetUpgrade ¶
func (u *UpgradeChecker) GetUpgrade(height int64) (*Upgrade, error)
func (*UpgradeChecker) ShouldUpgrade ¶
func (u *UpgradeChecker) ShouldUpgrade(height int64) bool
func (*UpgradeChecker) WatchConfigFile ¶
func (u *UpgradeChecker) WatchConfigFile() error
type UpgradeSource ¶
type UpgradeSource string
const ( UpgradeScheduled = "scheduled" ManualUpgrade UpgradeSource = "manual" OnChainUpgrade UpgradeSource = "on-chain" )
type UpgradesConfig ¶
type UpgradesConfig struct {
Upgrades []Upgrade `json:"upgrades"`
}