Documentation
¶
Index ¶
- Variables
- func Decode(dst any, mapData map[string]any, opts ...DecoderConfigOption) error
- func GetRegisteredConfigCenter() map[string]ConfigCenter
- func NewGlobal[C Config, D Dao](configCenter ...ConfigCenter) *globalConfig[C, D]
- func NewGlobalConfig[C Config](configCenter ...ConfigCenter) *globalConfig[C, *EmbeddedPresets]
- func NewGlobalWith[C Config, D Dao](conf C, dao D, configCenter ...ConfigCenter) *globalConfig[C, D]
- func RegisterConfigCenter(c ConfigCenter)
- func RegisterUnSupportTemplateTypes(types ...string)
- func Start[C Config, D Dao](conf C, dao D, configCenter ...ConfigCenter) func()
- type BasicConfig
- type Client
- type CloseFunc
- type Config
- type ConfigCenter
- type ConfigCenterConfig
- type ConfigType
- type Dao
- type DaoConfig
- type DaoField
- type DaoG
- type DecoderConfigOption
- type EmbeddedPresets
- type EnvConfig
- type Init
- type Local
- type LogConfig
- type RootConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var DaoFieldType = reflect.TypeOf((*DaoField)(nil)).Elem()
View Source
var EmbeddedPresetsType = reflect.TypeOf((*EmbeddedPresets)(nil)).Elem()
Functions ¶
func Decode ¶ added in v0.13.5
func Decode(dst any, mapData map[string]any, opts ...DecoderConfigOption) error
func GetRegisteredConfigCenter ¶ added in v0.13.12
func GetRegisteredConfigCenter() map[string]ConfigCenter
func NewGlobal ¶ added in v0.4.0
func NewGlobal[C Config, D Dao](configCenter ...ConfigCenter) *globalConfig[C, D]
var Global = initialize.NewGlobal[C,D]()
func NewGlobalConfig ¶ added in v0.9.0
func NewGlobalConfig[C Config](configCenter ...ConfigCenter) *globalConfig[C, *EmbeddedPresets]
func NewGlobalWith ¶ added in v0.4.0
func NewGlobalWith[C Config, D Dao](conf C, dao D, configCenter ...ConfigCenter) *globalConfig[C, D]
func RegisterConfigCenter ¶ added in v0.13.12
func RegisterConfigCenter(c ConfigCenter)
func RegisterUnSupportTemplateTypes ¶ added in v0.12.0
func RegisterUnSupportTemplateTypes(types ...string)
func Start ¶
func Start[C Config, D Dao](conf C, dao D, configCenter ...ConfigCenter) func()
Types ¶
type BasicConfig ¶ added in v0.13.12
type BasicConfig struct {
// 模块名
Name string `flag:"name:name;usage:模块名;env:NAME"`
// environment
Env string `flag:"name:env;short:e;default:dev;usage:环境;env:ENV"`
}
BasicConfig
type ConfigCenter ¶ added in v0.13.12
type ConfigCenter interface {
Config() any
io.Closer
Handle(ctx context.Context, merge func(io.Reader) error, onChange func(io.Reader) error) error
Type() string
}
func GetConfigCenter ¶ added in v0.13.12
func GetConfigCenter(configType string) ConfigCenter
type ConfigCenterConfig ¶ added in v0.13.12
type ConfigCenterConfig struct {
// 配置格式
Format string `flag:"name:format;usage:配置格式"`
// 配置类型
Type string `flag:"name:conf_type;usage:配置类型"`
// config字段顺序不能变,ConfigCenter 保持在最后
ConfigCenter ConfigCenter
}
type ConfigType ¶ added in v0.13.12
type ConfigType string
type DaoG ¶ added in v0.13.12
type DecoderConfigOption ¶ added in v0.13.5
type DecoderConfigOption func(*mapstructure.DecoderConfig)
type EmbeddedPresets ¶
type EmbeddedPresets struct {
}
func (*EmbeddedPresets) AfterInject ¶ added in v0.0.33
func (u *EmbeddedPresets) AfterInject()
func (*EmbeddedPresets) AfterInjectConfig ¶ added in v0.0.33
func (u *EmbeddedPresets) AfterInjectConfig()
func (*EmbeddedPresets) BeforeInject ¶ added in v0.0.33
func (u *EmbeddedPresets) BeforeInject()
type EnvConfig ¶ added in v0.13.12
type EnvConfig struct {
Debug bool `flag:"name:debug;short:d;default:true;usage:是否测试;env:DEBUG"`
ConfigTemplateDir string `flag:"name:conf_tmpl_dir;usage:是否生成配置模板;env:CONFIG_TEMPLATE_DIR"`
// 代理, socks5://localhost:1080
Proxy string `flag:"name:proxy;usage:代理;env:HTTP_PROXY" `
SkipInjectDaos []string `flag:"name:skip_inject_daos;usage:跳过注入的dao"`
LocalConfig Local
// config字段顺序不能变,ConfigCenter 保持在最后
ConfigCenter ConfigCenterConfig
}
func (*EnvConfig) AfterInject ¶ added in v0.13.12
func (c *EnvConfig) AfterInject()
type Local ¶ added in v0.6.0
type LogConfig ¶ added in v0.13.12
全局变量,只一个实例,只提供config
func (*LogConfig) AfterInjectWithRoot ¶ added in v0.13.12
func (c *LogConfig) AfterInjectWithRoot(rootconfig *RootConfig)
type RootConfig ¶ added in v0.13.12
type RootConfig struct {
Executable string `init:"-"` // autowired
ExecDir string `init:"-"` // autowired
// 配置文件路径
ConfPath string `flag:"name:config;short:c;usage:配置文件路径,默认./config.xxx或./config/config.xxx;env:CONFIG"`
BasicConfig
EnvConfig
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.
