config

package
v0.0.0-...-1338f1b Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 23 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDefaultScheduler

func IsDefaultScheduler(typ string) bool

IsDefaultScheduler checks whether the scheduler is enable by default.

func ParseUrls

func ParseUrls(s string) ([]url.URL, error)

ParseUrls parse a string into multiple urls. Export for api.

Types

type Config

type Config struct {
	*flag.FlagSet `json:"-"`

	Version bool `json:"-"`

	ConfigCheck bool `json:"-"`

	ClientUrls          string `toml:"client-urls" json:"client-urls"`
	PeerUrls            string `toml:"peer-urls" json:"peer-urls"`
	AdvertiseClientUrls string `toml:"advertise-client-urls" json:"advertise-client-urls"`
	AdvertisePeerUrls   string `toml:"advertise-peer-urls" json:"advertise-peer-urls"`

	Name              string `toml:"name" json:"name"`
	DataDir           string `toml:"data-dir" json:"data-dir"`
	ForceNewCluster   bool   `json:"force-new-cluster"`
	EnableGRPCGateway bool   `json:"enable-grpc-gateway"`

	InitialCluster      string `toml:"initial-cluster" json:"initial-cluster"`
	InitialClusterState string `toml:"initial-cluster-state" json:"initial-cluster-state"`

	// LeaderLease time, if leader doesn't update its TTL
	// in etcd after lease time, etcd will expire the leader key
	// and other servers can campaign the leader again.
	// Etcd only supports seconds TTL, so here is second too.
	LeaderLease int64 `toml:"lease" json:"lease"`

	// Log related config.
	Log log.Config `toml:"log" json:"log"`

	// Backward compatibility.
	LogFileDeprecated  string `toml:"log-file" json:"log-file"`
	LogLevelDeprecated string `toml:"log-level" json:"log-level"`

	// TsoSaveInterval is the interval to save timestamp.
	TsoSaveInterval typeutil.Duration `toml:"tso-save-interval" json:"tso-save-interval"`

	Schedule ScheduleConfig `toml:"schedule" json:"schedule"`

	Replication ReplicationConfig `toml:"replication" json:"replication"`

	PDServerCfg PDServerConfig `toml:"pd-server" json:"pd-server"`

	// 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 typeutil.ByteSize `toml:"quota-backend-bytes" json:"quota-backend-bytes"`
	// AutoCompactionMode is either 'periodic' or 'revision'. The default value is 'periodic'.
	AutoCompactionMode string `toml:"auto-compaction-mode" json:"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" json:"auto-compaction-retention-v2"`

	// TickInterval is the interval for etcd Raft tick.
	TickInterval typeutil.Duration `toml:"tick-interval"`
	// ElectionInterval is the interval for etcd Raft election.
	ElectionInterval typeutil.Duration `toml:"election-interval"`

	Security SecurityConfig `toml:"security" json:"security"`

	// For all warnings during parsing.
	WarningMsgs []string

	DisableStrictReconfigCheck bool

	HeartbeatStreamBindInterval typeutil.Duration

	LeaderPriorityCheckInterval typeutil.Duration
	// contains filtered or unexported fields
}

Config is the pd server configuration.

func NewConfig

func NewConfig() *Config

NewConfig creates a new config.

func (*Config) Adjust

func (c *Config) Adjust(meta *toml.MetaData) error

Adjust is used to adjust the PD configurations.

func (*Config) Clone

func (c *Config) Clone() *Config

Clone returns a cloned configuration.

func (*Config) GenEmbedEtcdConfig

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

GenEmbedEtcdConfig generates a configuration for embedded etcd.

func (*Config) GetZapLogProperties

func (c *Config) GetZapLogProperties() *log.ZapProperties

GetZapLogProperties gets properties of the zap logger.

func (*Config) GetZapLogger

func (c *Config) GetZapLogger() *zap.Logger

GetZapLogger gets the created zap logger.

func (*Config) Parse

func (c *Config) Parse(arguments []string) error

Parse parses flag definitions from the argument list.

func (*Config) SetupLogger

func (c *Config) SetupLogger() error

SetupLogger setup the logger.

func (*Config) String

func (c *Config) String() string

func (*Config) Validate

func (c *Config) Validate() error

Validate is used to validate if some configurations are right.

type PDServerConfig

type PDServerConfig struct {
	// MaxResetTSGap is the max gap to reset the tso.
	MaxResetTSGap time.Duration `toml:"max-reset-ts-gap" json:"max-reset-ts-gap"`
}

PDServerConfig is the configuration for pd server.

type Replication

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

Replication provides some help to do replication.

func (*Replication) GetMaxReplicas

func (r *Replication) GetMaxReplicas() int

GetMaxReplicas returns the number of replicas for each region.

func (*Replication) Load

func (r *Replication) Load() *ReplicationConfig

Load returns replication configurations.

func (*Replication) SetMaxReplicas

func (r *Replication) SetMaxReplicas(replicas int)

SetMaxReplicas set the replicas for each region.

func (*Replication) Store

func (r *Replication) Store(cfg *ReplicationConfig)

Store sets replication configurations.

type ReplicationConfig

type ReplicationConfig struct {
	// MaxReplicas is the number of replicas for each region.
	MaxReplicas uint64 `toml:"max-replicas,omitempty" json:"max-replicas"`
}

ReplicationConfig is the replication configuration.

type ScheduleConfig

type ScheduleConfig struct {
	// PatrolRegionInterval is the interval for scanning region during patrol.
	PatrolRegionInterval typeutil.Duration `toml:"patrol-region-interval,omitempty" json:"patrol-region-interval"`
	// MaxStoreDownTime is the max duration after which
	// a store will be considered to be down if it hasn't reported heartbeats.
	MaxStoreDownTime typeutil.Duration `toml:"max-store-down-time,omitempty" json:"max-store-down-time"`
	// LeaderScheduleLimit is the max coexist leader schedules.
	LeaderScheduleLimit uint64 `toml:"leader-schedule-limit,omitempty" json:"leader-schedule-limit"`
	// RegionScheduleLimit is the max coexist region schedules.
	RegionScheduleLimit uint64 `toml:"region-schedule-limit,omitempty" json:"region-schedule-limit"`
	// ReplicaScheduleLimit is the max coexist replica schedules.
	ReplicaScheduleLimit uint64 `toml:"replica-schedule-limit,omitempty" json:"replica-schedule-limit"`

	// Schedulers support for loading customized schedulers
	Schedulers SchedulerConfigs `toml:"schedulers,omitempty" json:"schedulers-v2"` // json v2 is for the sake of compatible upgrade

	// Only used to display
	SchedulersPayload map[string]string `json:"schedulers,omitempty"`
}

ScheduleConfig is the schedule configuration.

func (*ScheduleConfig) Clone

func (c *ScheduleConfig) Clone() *ScheduleConfig

Clone returns a cloned scheduling configuration.

func (*ScheduleConfig) Validate

func (c *ScheduleConfig) Validate() error

Validate is used to validate if some scheduling configurations are right.

type ScheduleOption

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

ScheduleOption is a wrapper to access the configuration safely.

func NewScheduleOption

func NewScheduleOption(cfg *Config) *ScheduleOption

NewScheduleOption creates a new ScheduleOption.

func (*ScheduleOption) AddSchedulerCfg

func (o *ScheduleOption) AddSchedulerCfg(tp string, args []string)

AddSchedulerCfg adds the scheduler configurations.

func (*ScheduleOption) GetLeaderScheduleLimit

func (o *ScheduleOption) GetLeaderScheduleLimit() uint64

GetLeaderScheduleLimit returns the limit for leader schedule.

func (*ScheduleOption) GetMaxReplicas

func (o *ScheduleOption) GetMaxReplicas() int

GetMaxReplicas returns the number of replicas for each region.

func (*ScheduleOption) GetMaxStoreDownTime

func (o *ScheduleOption) GetMaxStoreDownTime() time.Duration

GetMaxStoreDownTime returns the max down time of a store.

func (*ScheduleOption) GetPatrolRegionInterval

func (o *ScheduleOption) GetPatrolRegionInterval() time.Duration

GetPatrolRegionInterval returns the interval of patroling region.

func (*ScheduleOption) GetRegionScheduleLimit

func (o *ScheduleOption) GetRegionScheduleLimit() uint64

GetRegionScheduleLimit returns the limit for region schedule.

func (*ScheduleOption) GetReplicaScheduleLimit

func (o *ScheduleOption) GetReplicaScheduleLimit() uint64

GetReplicaScheduleLimit returns the limit for replica schedule.

func (*ScheduleOption) GetReplication

func (o *ScheduleOption) GetReplication() *Replication

GetReplication returns replication configurations.

func (*ScheduleOption) GetSchedulers

func (o *ScheduleOption) GetSchedulers() SchedulerConfigs

GetSchedulers gets the scheduler configurations.

func (*ScheduleOption) Load

func (o *ScheduleOption) Load() *ScheduleConfig

Load returns scheduling configurations.

func (*ScheduleOption) LoadPDServerConfig

func (o *ScheduleOption) LoadPDServerConfig() *PDServerConfig

LoadPDServerConfig returns PD server configurations.

func (*ScheduleOption) RemoveSchedulerCfg

func (o *ScheduleOption) RemoveSchedulerCfg(ctx context.Context, name string) error

RemoveSchedulerCfg removes the scheduler configurations.

func (*ScheduleOption) SetMaxReplicas

func (o *ScheduleOption) SetMaxReplicas(replicas int)

SetMaxReplicas sets the number of replicas for each region.

func (*ScheduleOption) Store

func (o *ScheduleOption) Store(cfg *ScheduleConfig)

Store sets scheduling configurations.

type SchedulerConfig

type SchedulerConfig struct {
	Type        string   `toml:"type" json:"type"`
	Args        []string `toml:"args,omitempty" json:"args"`
	Disable     bool     `toml:"disable" json:"disable"`
	ArgsPayload string   `toml:"args-payload,omitempty" json:"args-payload"`
}

SchedulerConfig is customized scheduler configuration

type SchedulerConfigs

type SchedulerConfigs []SchedulerConfig

SchedulerConfigs is a slice of customized scheduler configuration.

type SecurityConfig

type SecurityConfig struct {
	// CAPath is the path of file that contains list of trusted SSL CAs. if set, following four settings shouldn't be empty
	CAPath string `toml:"cacert-path" json:"cacert-path"`
	// CertPath is the path of file that contains X509 certificate in PEM format.
	CertPath string `toml:"cert-path" json:"cert-path"`
	// KeyPath is the path of file that contains X509 key in PEM format.
	KeyPath string `toml:"key-path" json:"key-path"`
}

SecurityConfig is the configuration for supporting tls.

func (SecurityConfig) ToTLSConfig

func (s SecurityConfig) ToTLSConfig() (*tls.Config, error)

ToTLSConfig generatres tls config.

Jump to

Keyboard shortcuts

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