mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-01 15:31:29 +08:00
better locks
This commit is contained in:
parent
819a85f59a
commit
e2c7e3fe6d
@ -52,6 +52,10 @@ type ViperProxy struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
vp = &ViperProxy{}
|
||||||
|
)
|
||||||
|
|
||||||
func (vp *ViperProxy) SetDefault(key string, value interface{}) {
|
func (vp *ViperProxy) SetDefault(key string, value interface{}) {
|
||||||
vp.Lock()
|
vp.Lock()
|
||||||
defer vp.Unlock()
|
defer vp.Unlock()
|
||||||
@ -83,10 +87,15 @@ func (vp *ViperProxy) GetStringSlice(key string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetViper() *ViperProxy {
|
func GetViper() *ViperProxy {
|
||||||
v := &ViperProxy{}
|
vp.Lock()
|
||||||
v.Viper = viper.GetViper()
|
defer vp.Unlock()
|
||||||
v.AutomaticEnv()
|
|
||||||
v.SetEnvPrefix("weed")
|
if vp.Viper == nil {
|
||||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
vp.Viper = viper.GetViper()
|
||||||
return v
|
vp.AutomaticEnv()
|
||||||
|
vp.SetEnvPrefix("weed")
|
||||||
|
vp.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return vp
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user