config

package
v0.52.16 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir added in v0.51.5

func ConfigDir() (string, error)

ConfigDir returns the path to the DeBros config directory (~/.debros).

func DecodeStrict added in v0.51.5

func DecodeStrict(r io.Reader, out interface{}) error

DecodeStrict decodes YAML from a reader and rejects any unknown fields. This ensures the YAML only contains recognized configuration keys.

func DefaultPath added in v0.51.5

func DefaultPath(component string) (string, error)

DefaultPath returns the path to the config file for the given component name. component should be e.g., "node.yaml", "bootstrap.yaml", "gateway.yaml"

func EnsureConfigDir added in v0.51.5

func EnsureConfigDir() (string, error)

EnsureConfigDir creates the config directory if it does not exist.

Types

type ClientConfig

type ClientConfig struct {
	AppName        string        `yaml:"app_name"`
	DatabaseName   string        `yaml:"database_name"`
	BootstrapPeers []string      `yaml:"bootstrap_peers"`
	ConnectTimeout time.Duration `yaml:"connect_timeout"`
	RetryAttempts  int           `yaml:"retry_attempts"`
}

ClientConfig represents configuration for network clients

type Config

type Config struct {
	Node      NodeConfig      `yaml:"node"`
	Database  DatabaseConfig  `yaml:"database"`
	Discovery DiscoveryConfig `yaml:"discovery"`
	Security  SecurityConfig  `yaml:"security"`
	Logging   LoggingConfig   `yaml:"logging"`
}

Config represents the main configuration for a network node

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration

func (*Config) ParseMultiaddrs

func (c *Config) ParseMultiaddrs() ([]multiaddr.Multiaddr, error)

ParseMultiaddrs converts string addresses to multiaddr objects

func (*Config) Validate added in v0.51.5

func (c *Config) Validate() []error

Validate performs comprehensive validation of the entire config. It aggregates all errors and returns them, allowing the caller to print all issues at once.

type DatabaseConfig

type DatabaseConfig struct {
	DataDir           string        `yaml:"data_dir"`
	ReplicationFactor int           `yaml:"replication_factor"`
	ShardCount        int           `yaml:"shard_count"`
	MaxDatabaseSize   int64         `yaml:"max_database_size"` // In bytes
	BackupInterval    time.Duration `yaml:"backup_interval"`

	// RQLite-specific configuration
	RQLitePort        int    `yaml:"rqlite_port"`         // RQLite HTTP API port
	RQLiteRaftPort    int    `yaml:"rqlite_raft_port"`    // RQLite Raft consensus port
	RQLiteJoinAddress string `yaml:"rqlite_join_address"` // Address to join RQLite cluster
}

DatabaseConfig contains database-related configuration

type DiscoveryConfig

type DiscoveryConfig struct {
	BootstrapPeers    []string      `yaml:"bootstrap_peers"`    // Bootstrap peer addresses
	DiscoveryInterval time.Duration `yaml:"discovery_interval"` // Discovery announcement interval
	BootstrapPort     int           `yaml:"bootstrap_port"`     // Default port for bootstrap nodes
	HttpAdvAddress    string        `yaml:"http_adv_address"`   // HTTP advertisement address
	RaftAdvAddress    string        `yaml:"raft_adv_address"`   // Raft advertisement
	NodeNamespace     string        `yaml:"node_namespace"`     // Namespace for node identifiers
}

DiscoveryConfig contains peer discovery configuration

type LoggingConfig

type LoggingConfig struct {
	Level      string `yaml:"level"`       // debug, info, warn, error
	Format     string `yaml:"format"`      // json, console
	OutputFile string `yaml:"output_file"` // Empty for stdout
}

LoggingConfig contains logging configuration

type NodeConfig

type NodeConfig struct {
	ID              string   `yaml:"id"`               // Auto-generated if empty
	Type            string   `yaml:"type"`             // "bootstrap" or "node"
	ListenAddresses []string `yaml:"listen_addresses"` // LibP2P listen addresses
	DataDir         string   `yaml:"data_dir"`         // Data directory
	MaxConnections  int      `yaml:"max_connections"`  // Maximum peer connections
}

NodeConfig contains node-specific configuration

type SecurityConfig

type SecurityConfig struct {
	EnableTLS       bool   `yaml:"enable_tls"`
	PrivateKeyFile  string `yaml:"private_key_file"`
	CertificateFile string `yaml:"certificate_file"`
}

SecurityConfig contains security-related configuration

type ValidationError added in v0.51.5

type ValidationError struct {
	Path    string // e.g., "discovery.bootstrap_peers[0]"
	Message string // e.g., "invalid multiaddr"
	Hint    string // e.g., "expected /ip{4,6}/.../tcp/<port>/p2p/<peerID>"
}

ValidationError represents a single validation error with context.

func (ValidationError) Error added in v0.51.5

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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