Documentation ¶
Overview ¶
Package base provide some basic functions
Index ¶
- Constants
- func GetBuildDir() string
- func GetBuildGo() string
- func GetBuildTime() string
- func GetBuildVCS() []string
- func GetExecDir() string
- func GetExecName() string
- func GetPath(p ...string) string
- func GetPathWork(p ...string) string
- func GetReloadTime() time.Time
- func GetStartTime() time.Time
- func GetWorkDir() string
- func LiteMode() bool
- func LiteModeDisable()
- func LiteModeEnable()
- func Reload(args ...FuncLevel)
- func ReloadCancel(key string, args ...FuncLevel)
- func ReloadRegister(key string, function func(context.Context) error, args ...FuncLevel)
- func Retire(code int, args ...bool)
- func RetireCancel(key string, args ...FuncLevel)
- func RetireRegister(key string, function func(context.Context) error, args ...FuncLevel)
- func Shadow()
- func TestMode() bool
- type Config
- type FuncLevel
- type Logger
- type LoggerOption
- type Option
Constants ¶
const ( // AllFuncLevelMask indicates all levels AllFuncLevelMask FuncLevel = ^FuncLevel(0) // MinorFuncLevelMask contains minor level MinorFuncLevelMask = MinorFuncLevel // MajorFuncLevelMask contains major level and minor level MajorFuncLevelMask = MajorFuncLevel | MinorFuncLevel // LoggerFuncLevelMask contains logger level LoggerFuncLevelMask = loggerReloadLevel | loggerLevelLevel // PrimaryLevelMask contains logger mask and primary mask PrimaryFuncLevelMask = LoggerFuncLevelMask | MajorFuncLevelMask )
LevelMask
Variables ¶
This section is empty.
Functions ¶
func GetBuildDir ¶
func GetBuildDir() string
GetBuildDir return directory that set by LDFLAGS at building
func GetBuildTime ¶
func GetBuildTime() string
GetBuildTime return time that set by LDFLAGS at building
func GetBuildVCS ¶
func GetBuildVCS() []string
GetBuildVCS return version control system information
func GetPath ¶
GetPath return the absolute path relative to the binary file by input
func GetPathWork ¶
GetPathWork return the absolute path relative to the work directory by input
func ReloadCancel ¶
ReloadCancel cancel a function that has been registered by ReloadRegister
func ReloadRegister ¶
ReloadRegister register a function that will be executed while reload
func Retire ¶
Retire will execute all functions registered Shadow process will be started if args[0] is true
func RetireCancel ¶
RetireCancel cancel a function that has been registered by RetireRegister
func RetireRegister ¶
RetireRegister register a function that will be executed while retire
Types ¶
type Config ¶
Config wrap *viper.Viper
type FuncLevel ¶
type FuncLevel uint8
FuncLevel indicates level of a function Functions in same level with be executed in parallel
const ( // MajorFuncLevel is used for normal functions that execute firstly MajorFuncLevel FuncLevel // MinorFuncLevel is used for normal functions that execute secondly MinorFuncLevel )
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
Logger wrap *zap.SugaredLogger
type LoggerOption ¶
type LoggerOption struct { Level *Option Filename *Option Directory *Option Compress *Option Stderr *Option MaxAge *Option MaxSize *Option MaxBackups *Option }
LoggerOption for Logger
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option contains a default value and bind key with a *Config
func NewOption ¶
NewOption return an *Option
func (*Option) Duration ¶
Duration return time.Duration value of *Option
func (*Option) IsSet ¶ added in v0.1.3
IsSet checks to see if the key has been set in config file