Documentation
¶
Index ¶
- func NewConfigTestCmd(config VerifiableConfig) *cobra.Command
- func NewTracedE(err error) error
- func NewTracedEf(format string, a ...interface{}) error
- func NewVersionCmd(version string) *cobra.Command
- func NewWrapEf(format string, a ...interface{}) error
- func WaitForQuitSignal()
- func WrapE(Err WrapError, err error) error
- func WrapEf(Err WrapError, format string, a ...interface{}) error
- type Config
- func (c *Config) EnableDbLog() bool
- func (c *Config) Env() string
- func (c *Config) GetMongoURI(id string) (mongoURI string, err error)
- func (c *Config) GetRedisURI(id string) (redisURI string, err error)
- func (c *Config) GetSQLSource(id string) (driver string, source string, err error)
- func (c *Config) GrpcListen() (network, address string)
- func (c *Config) HTTPListen() string
- func (c *Config) Init() error
- func (c *Config) Verify() error
- func (c *Config) Viper() *viper.Viper
- type ConfigLoader
- type ConfigVerifier
- type EnvConfig
- type EnvSetting
- type Envirment
- type FileConfigLoader
- type InternalError
- type JSONSchemaConfigVerifier
- type Mode
- type StringConfigLoader
- type TracedError
- type VerifiableConfig
- type WrapError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConfigTestCmd ¶
func NewConfigTestCmd(config VerifiableConfig) *cobra.Command
NewConfigTestCmd return a cobra command for configtest command: configtest
func NewTracedE ¶
NewTracedE create a new TracedError and wrap the given error into it
func NewTracedEf ¶
NewTracedEf create an error by format string and wrap it into a new TracedError
func NewVersionCmd ¶
NewVersionCmd return a cobra command to print giving version string command: version
func NewWrapEf ¶
NewWrapEf @deprecated use NewTracedEf instead create an error by format string and wrap it into a new TracedError
func WaitForQuitSignal ¶
func WaitForQuitSignal()
WaitForQuitSignal block until get a quit signal (SIGINT,SIGTERM) ,use for graceful stop
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config Config
func NewConfig ¶
func NewConfig(configloader ConfigLoader, configVerifier ConfigVerifier) *Config
NewConfig create a new config
func (*Config) EnableDbLog ¶
EnableDbLog get config for enable db Log
func (*Config) GetMongoURI ¶ added in v0.5.3
GetMongoURI get mongo connect string
func (*Config) GetRedisURI ¶
GetRedisURI get redis connect string
func (*Config) GetSQLSource ¶
GetSQLSource get driver and source string for sql connection
func (*Config) GrpcListen ¶
GrpcListen get grpc listen info
type ConfigLoader ¶
ConfigLoader load config interface
type ConfigVerifier ¶
ConfigVerifier verify config interface
type EnvConfig ¶
type EnvConfig interface { //get working mode string Env() string }
EnvConfig a config interface for envirment
type EnvSetting ¶
type EnvSetting struct {
// contains filtered or unexported fields
}
EnvSetting implement Envirment interface
func NewEnvSetting ¶
func NewEnvSetting(config EnvConfig) *EnvSetting
NewEnvSetting generate new EnvSetting
type Envirment ¶
type Envirment interface { //Return working mode Mode() Mode }
Envirment envirment interface
type FileConfigLoader ¶
FileConfigLoader load config from file system
func NewFileConfigLoader ¶
func NewFileConfigLoader(filename, configType string) *FileConfigLoader
NewFileConfigLoader create a new file config loader
func (*FileConfigLoader) LoadConfig ¶
func (l *FileConfigLoader) LoadConfig(vc *viper.Viper) error
LoadConfig ConfigLoader implement
type InternalError ¶
type InternalError struct{ TracedError }
InternalError an error for framework internal use
type JSONSchemaConfigVerifier ¶
type JSONSchemaConfigVerifier struct {
Schema string
}
JSONSchemaConfigVerifier verfiy config by jsonschema
func NewJSONSchemaConfigVerifier ¶
func NewJSONSchemaConfigVerifier(schema string) *JSONSchemaConfigVerifier
NewJSONSchemaConfigVerifier create a new jsonschema config verifier
func (JSONSchemaConfigVerifier) VerfiyConfig ¶
func (jv JSONSchemaConfigVerifier) VerfiyConfig(vc *viper.Viper) error
VerfiyConfig ConfigVerifier interface
type StringConfigLoader ¶
StringConfigLoader load config from string
func NewStringConfigLoader ¶
func NewStringConfigLoader(str, configType string) *StringConfigLoader
NewStringConfigLoader NewStringConfigLoader
func (*StringConfigLoader) LoadConfig ¶
func (l *StringConfigLoader) LoadConfig(vc *viper.Viper) error
LoadConfig ConfigLoader implement
type TracedError ¶
TracedError a WrapError store the position where error occur
func (*TracedError) Wrap ¶
func (e *TracedError) Wrap(err error)
Wrap WrapError interface,do not call this function directly , use WrapE func instead
type VerifiableConfig ¶
type VerifiableConfig interface {
Verify() error
}
VerifiableConfig a config interface for config test
Directories
¶
Path | Synopsis |
---|---|
db
|
|
api
Package api 提供api 相关的一些定义和工具函数
|
Package api 提供api 相关的一些定义和工具函数 |
api/middleware
Package middleware 自定义 api 中间键包,提供常用业务场景中会使用到的一些中间键封装 某些自定义功能可能会需要几个中间键组合在一起才能生效
|
Package middleware 自定义 api 中间键包,提供常用业务场景中会使用到的一些中间键封装 某些自定义功能可能会需要几个中间键组合在一起才能生效 |
util
|
|
curl
Package curl 封装go 标准http 库使其支持类似curl 的调用
|
Package curl 封装go 标准http 库使其支持类似curl 的调用 |
jsonschema
Package jsonschema 提供利用 jsonschema 来进行json 验证的一些工具函数
|
Package jsonschema 提供利用 jsonschema 来进行json 验证的一些工具函数 |
random
Package random provides tools for some random string
|
Package random provides tools for some random string |