config

package
v3.2.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0, MIT Imports: 13 Imported by: 10

Documentation

Index

Constants

View Source
const (
	LocalSingleAddr = "127.0.0.1"
	LocalCastAddr   = "0.0.0.0"
)

Variables

This section is empty.

Functions

func GetBuildTime

func GetBuildTime() string

func GetBuildVersion

func GetBuildVersion() string

func GetCommitID

func GetCommitID() string

func InitConfig

func InitConfig(path string)

func LoadConfig

func LoadConfig(conf *Config, path string)

func SetConfigVersion

func SetConfigVersion(bv, bt, ci string)

SetConfigVersion set the version, time and commit id of build

Types

type Base

type Base struct {
	Log         string   `toml:"log,omitempty" json:"log"`
	Level       string   `toml:"level,omitempty" json:"level"`
	LogFileNum  int      `toml:"log_file_num,omitempty" json:"log_file_num"`
	LogFileSize int      `toml:"log_file_size,omitempty" json:"log_file_size"`
	Data        []string `toml:"data,omitempty" json:"data"`
}

type Config

type Config struct {
	Global     *GlobalCfg `toml:"global,omitempty" json:"global"`
	EtcdConfig *EtcdCfg   `toml:"etcd,omitempty" json:"etcd"`
	Masters    Masters    `toml:"masters,omitempty" json:"masters"`
	Router     *RouterCfg `toml:"router,omitempty" json:"router"`
	PS         *PSCfg     `toml:"ps,omitempty" json:"ps"`
}

func Conf

func Conf() *Config

Conf return the single instance of config

func (*Config) CurrentByMasterNameDomainIp

func (config *Config) CurrentByMasterNameDomainIp(masterName string) error

CurrentByMasterNameDomainIp find this machine domain.The main purpose of this function is to find the master from from multiple masters and set it‘s Field:self to true. The only criterion for judging is: Is the IP address the same with one of the masters?

func (*Config) GetDataDir

func (c *Config) GetDataDir() string

func (*Config) GetDataDirBySlot

func (c *Config) GetDataDirBySlot(model Model, pid uint32) string

func (*Config) GetDatas

func (c *Config) GetDatas() []string

func (*Config) GetEmbed

func (config *Config) GetEmbed() (*embed.Config, error)

GetEmbed will get or generate the etcd configuration

func (*Config) GetEtcdAddress

func (this *Config) GetEtcdAddress() []string

get etcd address config

func (*Config) GetLevel

func (c *Config) GetLevel() string

make sure it not use in loop

func (*Config) GetLogDir

func (c *Config) GetLogDir() string

func (*Config) GetLogFileNum

func (c *Config) GetLogFileNum() int

func (*Config) GetLogFileSize

func (c *Config) GetLogFileSize() int

func (*Config) Validate

func (config *Config) Validate(model Model) error

type EtcdCfg

type EtcdCfg struct {
	AddressList    []string `toml:"address,omitempty" json:"address"`
	EtcdClientPort uint16   `toml:"etcd_client_port,omitempty" json:"etcd_client_port"`
	Username       string   `toml:"user_name,omitempty" json:"user_name"`
	Password       string   `toml:"password,omitempty" json:"password"`
}

type GlobalCfg

type GlobalCfg struct {
	Base
	Name            string `toml:"name,omitempty" json:"name"`
	Signkey         string `toml:"signkey,omitempty" json:"signkey"`
	SkipAuth        bool   `toml:"skip_auth,omitempty" json:"skip_auth"`
	SelfManageEtcd  bool   `toml:"self_manage_etcd,omitempty" json:"self_manage_etcd"`
	AutoRecoverPs   bool   `toml:"auto_recover_ps,omitempty" json:"auto_recover_ps"`
	SupportEtcdAuth bool   `toml:"support_etcd_auth,omitempty" json:"support_etcd_auth"`
	RaftConsistent  bool   `toml:"raft_consistent,omitempty" json:"raft_consistent"`
	MergeRouter     bool   `toml:"master_merge_into_router,omitempty" json:"master_merge_into_router"`
}

type MasterCfg

type MasterCfg struct {
	Name           string `toml:"name,omitempty" json:"name"`
	Address        string `toml:"address,omitempty" json:"address"`
	ApiPort        uint16 `toml:"api_port,omitempty" json:"api_port"`
	EtcdPort       uint16 `toml:"etcd_port,omitempty" json:"etcd_port"`
	EtcdPeerPort   uint16 `toml:"etcd_peer_port,omitempty" json:"etcd_peer_port"`
	EtcdClientPort uint16 `toml:"etcd_client_port,omitempty" json:"etcd_client_port"`
	Self           bool   `json:"-"`
	SkipAuth       bool   `toml:"skip_auth,omitempty" json:"skip_auth"`
	PprofPort      uint16 `toml:"pprof_port,omitempty" json:"pprof_port"`
	MonitorPort    uint16 `toml:"monitor_port" json:"monitor_port"`
}

func (*MasterCfg) ApiUrl

func (m *MasterCfg) ApiUrl() string

type Masters

type Masters []*MasterCfg

func (Masters) ClientAddress

func (ms Masters) ClientAddress() []string

new client use this function to get client urls

func (Masters) Self

func (ms Masters) Self() *MasterCfg

type Model

type Model int

Model start up model, include all, master, ps, router

const (
	Master Model = iota
	PS
	Router
)

type PSCfg

type PSCfg struct {
	RpcPort                uint16 `toml:"rpc_port,omitempty" json:"rpc_port"`
	PsHeartbeatTimeout     int    `toml:"ps_heartbeat_timeout" json:"ps_heartbeat_timeout"`
	RaftHeartbeatPort      uint16 `toml:"raft_heartbeat_port,omitempty" json:"raft_heartbeat_port"`
	RaftReplicatePort      uint16 `toml:"raft_replicate_port,omitempty" json:"raft_replicate_port"`
	RaftHeartbeatInterval  int    `toml:"heartbeat_interval" json:"heartbeat-interval"`
	RaftRetainLogs         uint64 `toml:"raft_retain_logs" json:"raft-retain-logs"`
	RaftReplicaConcurrency int    `toml:"raft_replica_concurrency" json:"raft-replica-concurrency"`
	RaftSnapConcurrency    int    `toml:"raft_snap_concurrency" json:"raft-snap-concurrency"`
	RaftTruncateCount      int64  `toml:"raft_truncate_count" json:"raft_truncate_count"`
	RaftDiffCount          uint64 `toml:"raft_diff_count" json:"raft_diff_count"`
	EngineDWPTNum          uint64 `toml:"engine_dwpt_num" json:"engine-dwpt-num"`
	MaxSize                int64  `toml:"max_size" json:"max_size"`
	PprofPort              uint16 `toml:"pprof_port" json:"pprof_port"`
	Private                bool   `toml:"private" json:"private"`                         //this ps is private if true you must set machine by dbConfig
	FlushTimeInterval      uint32 `toml:"flush_time_interval" json:"flush_time_interval"` // seconds
	FlushCountThreshold    uint32 `toml:"flush_count_threshold" json:"flush_count_threshold"`
}

type RouterCfg

type RouterCfg struct {
	Port         uint16   `toml:"port,omitempty" json:"port"`
	PprofPort    uint16   `toml:"pprof_port,omitempty" json:"pprof_port"`
	RpcPort      uint16   `toml:"rpc_port,omitempty" json:"rpc_port"`
	MonitorPort  uint16   `toml:"monitor_port" json:"monitor_port"`
	ConnLimit    int      `toml:"conn_limit" json:"conn_limit"`
	CloseTimeout int64    `toml:"close_timeout" json:"close_timeout"`
	RouterIPS    []string ``
}

func (*RouterCfg) ApiUrl

func (routerCfg *RouterCfg) ApiUrl(keyNumber int) string

Jump to

Keyboard shortcuts

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