config

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

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)

Types

type Base

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

type Config

type Config struct {
	Global  *GlobalCfg `toml:"global,omitempty" json:"global"`
	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

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 (this *Config) GetDataDir(model Model) string

func (*Config) GetDataDirBySlot

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

func (*Config) GetDatas

func (this *Config) GetDatas(model Model) []string

GetDataDir get the data directory configured in the config file

func (*Config) GetEmbed

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

GetEmbed will get or generate the etcd configuration

func (*Config) GetLevel

func (this *Config) GetLevel(model Model) string

make sure it not use in loop

func (*Config) GetLogDir

func (this *Config) GetLogDir(model Model) string

func (*Config) NewMonitor

func (config *Config) NewMonitor(model Model) monitoring.Monitor

func (*Config) Validate

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

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

type MasterCfg

type MasterCfg struct {
	Base
	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"`
}

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
const (
	Master Model = iota
	PS
	Router
)

type PSCfg

type PSCfg struct {
	Base
	RpcPort                uint16 `toml:"rpc_port,omitempty" json:"rpc_port"`
	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"`
	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
}

type RouterCfg

type RouterCfg struct {
	Base
	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"`
}

Jump to

Keyboard shortcuts

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