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