agent

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeFileNotFound     = "FILE_NOT_FOUND"
	ErrCodePermissionDenied = "PERMISSION_DENIED"
	ErrCodeReadError        = "READ_ERROR"
)
View Source
const DefaultServiceURL = "https://api.apphash.io"

DefaultServiceURL is the default endpoint for shipping WAL data.

Variables

This section is empty.

Functions

func ApplyEnvConfig

func ApplyEnvConfig(cfg *Config, changed map[string]bool) error

ApplyEnvConfig applies configuration from environment variables (WALSHIP_*). It respects flags that have been explicitly set (changed map). Returns error if any environment variable has an invalid format.

func ApplyFileConfig

func ApplyFileConfig(cfg *Config, fc fileConfig, changed map[string]bool) error

ApplyFileConfig applies configuration from a file to the Config struct. It respects flags that have been explicitly set (changed map).

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the default configuration file path.

func FileExists

func FileExists(p string) bool

FileExists checks if a file exists at the given path.

func LoadFileConfig

func LoadFileConfig(path string) (fileConfig, error)

LoadFileConfig reads and parses a TOML config file from the given path.

func LoadNodeInfo

func LoadNodeInfo(cfg *Config) error

LoadNodeInfo resolves ChainID and NodeID from explicit config or by querying the chain binary. It never reads private key material from disk.

Resolution order for each field:

  1. Already set via flag / env / config file — keep as-is.
  2. ChainBinaryPath is set — query the binary.
  3. Neither — return an actionable error.

func Logger added in v1.2.0

func Logger() zerolog.Logger

Logger returns the package logger.

func Run

func Run(ctx context.Context, cfg Config) error

Types

type Config

type Config struct {
	NodeHome        string
	NodeID          string
	WALDir          string
	ChainBinaryPath string

	ChainID string

	ServiceURL string
	AuthKey    string

	PollInterval time.Duration
	SendInterval time.Duration
	HardInterval time.Duration
	HTTPTimeout  time.Duration

	CPUThreshold   float64
	NetThreshold   float64
	Iface          string
	IfaceSpeedMbps int
	MaxBatchBytes  int
	StateDir       string
	Verify         bool
	Meta           bool
	Once           bool
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with default values.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for errors and sets derived defaults.

type ConfigWatcher

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

ConfigWatcher monitors app.toml and config.toml changes via fsnotify.

func NewConfigWatcher

func NewConfigWatcher(cfg *Config) *ConfigWatcher

func (*ConfigWatcher) Run

func (w *ConfigWatcher) Run(ctx context.Context)

Run watches $NODE_HOME/config and sends updates to {ServiceURL}/config.

type FrameMeta

type FrameMeta struct {
	File    string `json:"file"`
	Frame   uint64 `json:"frame"`
	Off     uint64 `json:"off"`
	Len     uint64 `json:"len"`
	Recs    uint32 `json:"recs"`
	FirstTS int64  `json:"first_ts"`
	LastTS  int64  `json:"last_ts"`
	CRC32   uint32 `json:"crc32"`
}

FrameMeta matches tools/memlogger/writer.go schema for index lines. Fields are used to locate and read gzip members from the .gz file.

Jump to

Keyboard shortcuts

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