fix race condition in config updating
This commit is contained in:
1 parent
40360f0c6f
commit
93b40f4c86
13 files changed
+272
-229
No files matched your search
+8
-1
@@ -35,13 +35,20 @@ func Global() *Config {
|
||||
return cfg
|
||||
}
|
||||
|
||||
func SetGlobal(c *Config) {
|
||||
func Set(c *Config) {
|
||||
globalMux.Lock()
|
||||
defer globalMux.Unlock()
|
||||
|
||||
global = c
|
||||
}
|
||||
|
||||
func OnUpdate(f func(c *Config) error) error {
|
||||
globalMux.Lock()
|
||||
defer globalMux.Unlock()
|
||||
|
||||
return f(global)
|
||||
}
|
||||
|
||||
type LogConfig struct {
|
||||
Output string `yaml:",omitempty" json:"output,omitempty"`
|
||||
Level string `yaml:",omitempty" json:"level,omitempty"`
|
||||
|
||||
Reference in new issue
Block a user