config

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 14 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

View Source
const (
	DefaultClusterName = "defaultCluster"
)

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"`
	FlowLimiter LimiterConfig `toml:"flow-limiter" env:"FLOW_LIMITER"`

	EnableEmbedEtcd    bool  `toml:"enable-embed-etcd" env:"ENABLE_EMBED_ETCD"`
	EtcdStartTimeoutMs int64 `toml:"etcd-start-timeout-ms" env:"ETCD_START_TIMEOUT_MS"`
	EtcdCallTimeoutMs  int64 `toml:"etcd-call-timeout-ms" env:"ETCD_CALL_TIMEOUT_MS"`
	EtcdMaxTxnOps      int64 `toml:"etcd-max-txn-ops" env:"ETCD_MAX_TXN_OPS"`

	GrpcHandleTimeoutMs                    int `toml:"grpc-handle-timeout-ms" env:"GRPC_HANDLER_TIMEOUT_MS"`
	GrpcServiceMaxSendMsgSize              int `toml:"grpc-service-max-send-msg-size" env:"GRPC_SERVICE_MAX_SEND_MSG_SIZE"`
	GrpcServiceMaxRecvMsgSize              int `toml:"grpc-service-max-recv-msg-size" env:"GRPC_SERVICE_MAX_RECV_MSG_SIZE"`
	GrpcServiceKeepAlivePingMinIntervalSec int `toml:"grpc-service-keep-alive-ping-min-interval-sec" env:"GRPC_SERVICE_KEEP_ALIVE_PING_MIN_INTERVAL_SEC"`

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

	NodeName            string `toml:"node-name" env:"NODE_NAME"`
	Addr                string `toml:"addr" env:"ADDR"`
	DataDir             string `toml:"data-dir" env:"DATA_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"`

	// When the EnableSchedule is turned on, the failover scheduling will be turned on, which is used for CeresDB cluster publishing and using local storage.
	EnableSchedule bool `toml:"enable-schedule" env:"ENABLE_SCHEDULE"`
	// TopologyType indicates the schedule type used by the CeresDB cluster, it will determine the strategy of CeresMeta scheduling cluster.
	TopologyType string `toml:"topology-type" env:"TOPOLOGY_TYPE"`
	// ProcedureExecutingBatchSize determines the maximum number of shards in a single batch when opening shards concurrently.
	ProcedureExecutingBatchSize uint32 `toml:"procedure-executing-batch-size" env:"PROCEDURE_EXECUTING_BATCH_SIZE"`

	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"`

	HTTPPort int `toml:"http-port" env:"HTTP_PORT"`
	GrpcPort int `toml:"grpc-port" env:"GRPC_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 LimiterConfig added in v1.2.1

type LimiterConfig struct {
	// Limit is the updated rate of tokens.
	Limit int `toml:"limit" env:"FLOW_LIMITER_LIMIT"`
	// Burst is the maximum number of tokens.
	Burst int `toml:"burst" env:"FLOW_LIMITER_BURST"`
	// Enable is used to control the switch of the limiter.
	Enable bool `toml:"enable" env:"FLOW_LIMITER_ENABLE"`
}

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) NeedPrintVersion added in v1.2.7

func (p *Parser) NeedPrintVersion() bool

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