config

package
v0.0.0-...-d1c0873 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConstConfigFile = "constcfg"
)

Variables

This section is empty.

Functions

func CheckOrStoreConstCfg

func CheckOrStoreConstCfg(fileDir, fileName string, cfg *ConstConfig) (ok bool, err error)

check listen port, raft replica port and raft heartbeat port

func NewIllegalConfigError

func NewIllegalConfigError(configKey string) error

Types

type Config

type Config struct {
	Raw []byte
	// contains filtered or unexported fields
}

Config defines the struct of a configuration in general.

func LoadConfigFile

func LoadConfigFile(filename string) (*Config, error)

LoadConfigFile loads config information from a JSON file.

func LoadConfigString

func LoadConfigString(s string) *Config

LoadConfigString loads config information from a JSON string.

func (*Config) CheckAndGetBool

func (c *Config) CheckAndGetBool(key string) (bool, bool)

GetBool returns a bool value for the config key.

func (*Config) CheckAndGetString

func (c *Config) CheckAndGetString(key string) (string, bool)

Check and get a string for the config key.

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

GetBool returns a bool value for the config key.

func (*Config) GetBoolWithDefault

func (c *Config) GetBoolWithDefault(key string, defval bool) bool

returns a bool value for the config key with default val when not present

func (*Config) GetFloat

func (c *Config) GetFloat(key string) float64

GetFloat returns a float value for the config key.

func (*Config) GetInt

func (c *Config) GetInt(key string) int64

GetBool returns a int value for the config key.

func (*Config) GetInt64

func (c *Config) GetInt64(key string) int64

GetBool returns a int64 value for the config key.

func (*Config) GetSlice

func (c *Config) GetSlice(key string) []interface{}

GetSlice returns an array for the config key.

func (*Config) GetString

func (c *Config) GetString(key string) string

GetString returns a string for the config key.

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string) []string

type ConstConfig

type ConstConfig struct {
	Listen           string `json:"listen"`
	RaftReplicaPort  string `json:"raftReplicaPort"`
	RaftHeartbetPort string `json:"raftHeartbetPort"`
}

func (*ConstConfig) Equals

func (ccfg *ConstConfig) Equals(cfg *ConstConfig) bool

Jump to

Keyboard shortcuts

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