Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigByPrefix ¶ added in v0.0.10
func NormalizeUnderscoreKeys ¶ added in v1.2.10
NormalizeUnderscoreKeys 让带下划线的配置键名也能被 Unmarshal 匹配到。
viper 的 Unmarshal 底层是 mapstructure,它只做大小写折叠、不做下划线归一化: 结构体字段 PoolSize 能匹配 poolsize / POOLSIZE,但匹配不上 pool_size。历史上 <NS>pool_size 这样的写法会被静默忽略,对应字段保持零值,排查起来很费劲。 这里在 Unmarshal 之前把带下划线的键补一份去掉下划线的写法。
两种写法并存时以**不带下划线的**为准。交给 mapstructure 自行处理的话,两个键 都会匹配上同一个字段,最终哪个生效取决于 map 的迭代顺序,是不确定的。
必须在 SetDefault 之前调用,否则 IsSet 会因为默认值而恒为真,感知不到用户实际 配的是哪种写法。
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application struct
func (*Application) Config ¶
func (d *Application) Config() *viper.Viper
Config returns the viper config for this application
func (*Application) Env ¶
func (d *Application) Env() string
func (*Application) Get ¶
func (d *Application) Get(key Key) Extension
Get the extension at the specified key, return nil when the component doesn't exist
func (*Application) GetOK ¶
func (d *Application) GetOK(key Key) (Extension, bool)
GetOK the extension at the specified key, return false when the component doesn't exist
func (*Application) Init ¶
func (d *Application) Init() error
Init the application and its extensions with the config.
type Extension ¶
type Extension interface {
Object() interface{}
Application() *Application
Init(app *Application) error
Close() error
}
Extension like db, cache
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gobay
command
|
|
|
echo
|
|
|
extensions
|
|
|
asynctaskext
How can I check that a running asynctask worker can otherwise process a new message within 5 seconds (health check)? - `curl 127.0.0.1:5000/health?timeout=5&queue=gobay.task_sub` - `curl 127.0.0.1:5000/health?timeout=5` **default queue**
|
How can I check that a running asynctask worker can otherwise process a new message within 5 seconds (health check)? - `curl 127.0.0.1:5000/health?timeout=5&queue=gobay.task_sub` - `curl 127.0.0.1:5000/health?timeout=5` **default queue** |
|
redisotelv6
Package redisotelv6 为 go-redis v6 客户端提供 OpenTelemetry 链路追踪。
|
Package redisotelv6 为 go-redis v6 客户端提供 OpenTelemetry 链路追踪。 |
|
utils
|
|