config

package
v1.0.0-alpha02 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHelpRequested      = coderr.NewCodeError(coderr.PrintHelpUsage, "help requested")
	ErrInvalidPeerURL     = coderr.NewCodeError(coderr.InvalidParams, "invalid peers url")
	ErrInvalidCommandArgs = coderr.NewCodeError(coderr.InvalidParams, "invalid command arguments")
	ErrRetrieveHostname   = coderr.NewCodeError(coderr.Internal, "retrieve local hostname")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Log     log.Config `toml:"log" env:"LOG"`
	EtcdLog log.Config `toml:"etcd-log" env:"ETCD_LOG"`

	GrpcHandleTimeoutMs int64 `toml:"grpc-handle-timeout-ms" env:"GRPC_HANDLER_TIMEOUT_MS"`
	EtcdStartTimeoutMs  int64 `toml:"etcd-start-timeout-ms" env:"ETCD_START_TIMEOUT_MS"`
	EtcdCallTimeoutMs   int64 `toml:"etcd-call-timeout-ms" env:"ETCD_CALL_TIMEOUT_MS"`

	LeaseTTLSec int64 `toml:"lease-sec" env:"LEASE_SEC"`

	NodeName            string `toml:"node-name" env:"NODE_NAME"`
	DataDir             string `toml:"data-dir" env:"DATA_DIR"`
	WalDir              string `toml:"wal-dir" env:"WAL_DIR"`
	StorageRootPath     string `toml:"storage-root-path" env:"STORAGE_ROOT_PATH"`
	InitialCluster      string `toml:"initial-cluster" env:"INITIAL_CLUSTER"`
	InitialClusterState string `toml:"initial-cluster-state" env:"INITIAL_CLUSTER_STATE"`
	InitialClusterToken string `toml:"initial-cluster-token" env:"INITIAL_CLUSTER_TOKEN"`
	// TickInterval is the interval for etcd Raft tick.
	TickIntervalMs    int64 `toml:"tick-interval-ms" env:"TICK_INTERVAL_MS"`
	ElectionTimeoutMs int64 `toml:"election-timeout-ms" env:"ELECTION_TIMEOUT_MS"`
	// QuotaBackendBytes Raise alarms when backend size exceeds the given quota. 0 means use the default quota.
	// the default size is 2GB, the maximum is 8GB.
	QuotaBackendBytes int64 `toml:"quota-backend-bytes" env:"QUOTA_BACKEND_BYTES"`
	// AutoCompactionMode is either 'periodic' or 'revision'. The default value is 'periodic'.
	AutoCompactionMode string `toml:"auto-compaction-mode" env:"AUTO-COMPACTION-MODE"`
	// AutoCompactionRetention is either duration string with time unit
	// (e.g. '5m' for 5-minute), or revision unit (e.g. '5000').
	// If no time unit is provided and compaction mode is 'periodic',
	// the unit defaults to hour. For example, '5' translates into 5-hour.
	// The default retention is 1 hour.
	// Before etcd v3.3.x, the type of retention is int. We add 'v2' suffix to make it backward compatible.
	AutoCompactionRetention string `toml:"auto-compaction-retention" env:"AUTO_COMPACTION_RETENTION"`
	MaxRequestBytes         uint   `toml:"max-request-bytes" env:"MAX_REQUEST_BYTES"`
	MaxScanLimit            int    `toml:"max-scan-limit" env:"MAX_SCAN_LIMIT"`
	MinScanLimit            int    `toml:"min-scan-limit" env:"MIN_SCAN_LIMIT"`
	IDAllocatorStep         uint   `toml:"id-allocator-step" env:"ID_ALLOCATOR_STEP"`

	// Following fields are the settings for the default cluster.
	DefaultClusterName              string `toml:"default-cluster-name" env:"DEFAULT_CLUSTER_NAME"`
	DefaultClusterNodeCount         int    `toml:"default-cluster-node-count" env:"DEFAULT_CLUSTER_NODE_COUNT"`
	DefaultClusterReplicationFactor int    `toml:"default-cluster-replication-factor" env:"DEFAULT_CLUSTER_REPLICATION_FACTOR"`
	DefaultClusterShardTotal        int    `toml:"default-cluster-shard-total" env:"DEFAULT_CLUSTER_SHARD_TOTAL"`

	ClientUrls          string `toml:"client-urls" env:"CLIENT_URLS"`
	PeerUrls            string `toml:"peer-urls" env:"PEER_URLS"`
	AdvertiseClientUrls string `toml:"advertise-client-urls" env:"ADVERTISE_CLIENT_URLS"`
	AdvertisePeerUrls   string `toml:"advertise-peer-urls" env:"ADVERTISE_PEER_URLS"`

	DefaultPartitionTableProportionOfNodes float32 `toml:"default-partition_table_proportion_of_nodes" env:"DEFAULT_PARTITION_TABLE_PROPORTION_OF_NODES"`

	HTTPPort int `toml:"default-http-port" env:"DEFAULT_HTTP_PORT"`
}

Config is server start config, it has three input modes: 1. toml config file 2. env variables Their loading has priority, and low priority configurations will be overwritten by high priority configurations. The priority from high to low is: env variables > toml config file.

func (*Config) EtcdCallTimeout

func (c *Config) EtcdCallTimeout() time.Duration

func (*Config) EtcdStartTimeout

func (c *Config) EtcdStartTimeout() time.Duration

func (*Config) GenEtcdConfig

func (c *Config) GenEtcdConfig() (*embed.Config, error)

func (*Config) GrpcHandleTimeout

func (c *Config) GrpcHandleTimeout() time.Duration

func (*Config) ValidateAndAdjust

func (c *Config) ValidateAndAdjust() error

ValidateAndAdjust validates the config fields and adjusts some fields which should be adjusted. Return error if any field is invalid.

type Parser

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

Parser builds the config from the flags.

func MakeConfigParser

func MakeConfigParser() (*Parser, error)

func (*Parser) Parse

func (p *Parser) Parse(arguments []string) (*Config, error)

func (*Parser) ParseConfigFromEnv added in v1.0.0

func (p *Parser) ParseConfigFromEnv() error

func (*Parser) ParseConfigFromToml added in v1.0.0

func (p *Parser) ParseConfigFromToml() error

ParseConfigFromToml read configuration from the toml file, if the config item already exists, it will be overwritten.

Jump to

Keyboard shortcuts

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