Documentation
¶
Overview ¶
Package config loads, parses, and validates per-node settings (from environment variables) and per-cluster settings (from a JSONC config file).
Index ¶
- func ValidateFile(path string, flags FlagOverrides) error
- func ValidateIdentifier(value, fieldName string) error
- type ChunkBufferConfig
- type ClusterConfig
- type Config
- type Duration
- type ElectorConfig
- type FlagOverrides
- type NodeConfig
- type ReplicationConfig
- type SnapshotConfig
- type StorageConfig
- type TLSFiles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateFile ¶
func ValidateFile(path string, flags FlagOverrides) error
ValidateFile loads and validates a config file without starting the server. Node config is still loaded from env vars (and flag overrides) so that cross-cutting validations such as node_id can run.
func ValidateIdentifier ¶
ValidateIdentifier checks that value is lowercase alphanumeric and hyphens, with no leading/trailing/consecutive hyphens, max 32 chars.
Types ¶
type ChunkBufferConfig ¶
type ClusterConfig ¶
type ClusterConfig struct {
ClusterID string `json:"cluster_id"`
Storage StorageConfig `json:"storage"`
HeartbeatInterval Duration `json:"heartbeat_interval"`
Elector ElectorConfig `json:"elector"`
Replication ReplicationConfig `json:"replication"`
Snapshot SnapshotConfig `json:"snapshot"`
CompactionInterval Duration `json:"compaction_interval"`
}
ClusterConfig holds per-cluster settings parsed from a JSONC config file.
func LoadClusterConfig ¶
func LoadClusterConfig(path string) (ClusterConfig, error)
LoadClusterConfig reads a JSONC config file, strips comments, and unmarshals it.
type Config ¶
type Config struct {
NodeConfig
ClusterConfig
// EtcdClusterID is a stable FNV-1a 64-bit hash of the string ClusterID,
// computed once at load time for use in etcd ResponseHeader.ClusterId.
EtcdClusterID uint64
}
Config combines per-node settings (from env vars) and per-cluster settings (from a JSONC config file).
func Load ¶
func Load(flags FlagOverrides) (*Config, error)
Load builds a fully validated Config from environment variables, the JSONC cluster config file, and any CLI flag overrides. It returns an error if the config file cannot be found/parsed or validation fails.
type Duration ¶
Duration wraps time.Duration to support JSON unmarshaling from string values like "5s", "10m", "1h30m", etc.
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type ElectorConfig ¶
type FlagOverrides ¶
FlagOverrides holds CLI flag values that override env-var defaults.
type NodeConfig ¶
type NodeConfig struct {
ConfigPath string // from NETSY_CONFIG env or --config flag
NodeID string // NETSY_NODE_ID
BindClient string // NETSY_BIND_CLIENT (default :2378)
AdvertiseClient string // NETSY_ADVERTISE_CLIENT
BindPeer string // NETSY_BIND_PEER (default :2381)
AdvertisePeer string // NETSY_ADVERTISE_PEER
BindElection string // NETSY_BIND_ELECTION (default :8443)
AdvertiseElection string // NETSY_ADVERTISE_ELECTION
BindHealth string // NETSY_BIND_HEALTH (default :8080)
TLSCACert string // NETSY_TLS_CA_CERT
TLSServerCert string // NETSY_TLS_SERVER_CERT
TLSServerKey string // NETSY_TLS_SERVER_KEY
TLSClientCert string // NETSY_TLS_CLIENT_CERT
TLSClientKey string // NETSY_TLS_CLIENT_KEY
DataDir string // NETSY_DATA_DIR (default /var/lib/netsy)
Verbose bool // NETSY_DEBUG
}
NodeConfig holds per-node settings populated from environment variables.
func LoadNodeConfig ¶
func LoadNodeConfig() NodeConfig
LoadNodeConfig reads environment variables and applies defaults.
type ReplicationConfig ¶
type ReplicationConfig struct {
Quorum *int `json:"quorum"` // default -1; 0 = disabled, -1 = majority, positive = static
DegradationCount int `json:"degradation_count"` // default 2
ChunkBuffer ChunkBufferConfig `json:"chunk_buffer"`
}
type SnapshotConfig ¶
type StorageConfig ¶
type StorageConfig struct {
Provider string `json:"provider"` // "s3" or "gcs", default "s3"
BucketName string `json:"bucket_name"`
KeyPrefix string `json:"key_prefix"`
Class string `json:"class"` // default "STANDARD"
Encryption string `json:"encryption"` // default "provider-managed"
KMSKeyID string `json:"kms_key_id"`
}
type TLSFiles ¶
type TLSFiles struct {
ServerCert *tls.Certificate
ServerCA *x509.CertPool
ClientCert *tls.Certificate
ClientCA *x509.CertPool
}
func LoadTLSFiles ¶
LoadTLSFiles loads the configured CA and certificate/key pairs and parses their leaf certificates for later validation.