Documentation
¶
Index ¶
- Constants
- Variables
- func GetLogLevel() string
- func GetNodeID() string
- func GetServerStartAt() uint64
- func InitialiseSystem() error
- func IsRunningTests() bool
- func Load(paths []string, conf *Config) error
- func SetGlobal(conf Config)
- func SetNodeID(nodeID string)
- func SetServerStartAt(st uint64)
- func SetTestMode(v bool)
- func WriteConf(path string, conf *Config) error
- func WriteDefault(path string, conf *Config) error
- type App
- type Config
- type DBConfig
- type LivenessCheckConfig
Constants ¶
const ( // AppName app name. AppName = "Galaxy" // VERSION mark app version. VERSION = "0.0.1" // AppLogLevel log level. AppLogLevel = "GALAXY_LOGLEVEL" )
const (
// MySQLDSNFormat string format
MySQLDSNFormat = "%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=Local"
)
Variables ¶
var ( // NodeID mark for current node. NodeID string // ServerStartAt Cache server start unix time. ServerStartAt uint64 )
Functions ¶
func InitialiseSystem ¶
func InitialiseSystem() error
InitialiseSystem done all things about app runtime env configurationss.
func IsRunningTests ¶
func IsRunningTests() bool
IsRunningTests returns true if current system is test mode.
func Load ¶
Load will load a configuration file, trying each of the paths given and using the first one that is a regular file and can be opened.
If none exists, a default config will be written to the first path in the list.
An error will be returned only if any of the paths existed but was not a valid config file.
func SetServerStartAt ¶
func SetServerStartAt(st uint64)
SetServerStartAt writes ServerStartAt safely.
func WriteDefault ¶
WriteDefault will set conf to the default config and write it to disk in path, if the path is non-empty.
Types ¶
type App ¶
type App struct { AppName string `json:"appName"` Version string `json:"version"` StartAt uint64 `json:"startAt"` NodeID string `json:"nodeID"` }
App cache node info.
type Config ¶
type Config struct { // OriginalPath is the path to the config file that was read. If // none was found, it's the path to the default config file that // was written. OriginalPath string `json:"-"` TemplatePath string `json:"template_path"` PIDFileLocation string `json:"pid_file_location"` LivenessCheck LivenessCheckConfig `json:"liveness_check"` MySQLConfig DBConfig `json:"mysql_config"` App App `json:"app"` }
Config global configs.
type DBConfig ¶
type DBConfig struct { User string `json:"user"` Password string `json:"password"` Host string `json:"host"` Port int `json:"port"` Database string `json:"database"` }
DBConfig defines for DB connection.
type LivenessCheckConfig ¶
LivenessCheckConfig liveness check duration.