aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-01-13 13:14:48 -0800
committerChris Lu <chris.lu@gmail.com>2021-01-13 13:14:52 -0800
commit819a85f59aad5f8e1e8a46f9bba705cb31db7af5 (patch)
tree7821b1882cacfc8f13b4eb2578df0f41df55310c
parent3c5b0ed8e37ae503f355cfad92d0059a44007cc7 (diff)
downloadseaweedfs-819a85f59aad5f8e1e8a46f9bba705cb31db7af5.tar.xz
seaweedfs-819a85f59aad5f8e1e8a46f9bba705cb31db7af5.zip
avoid viper concurrent access
-rw-r--r--weed/util/config.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/util/config.go b/weed/util/config.go
index 54edf5a3c..e746b0bd1 100644
--- a/weed/util/config.go
+++ b/weed/util/config.go
@@ -58,6 +58,30 @@ func (vp *ViperProxy) SetDefault(key string, value interface{}) {
vp.Viper.SetDefault(key, value)
}
+func (vp *ViperProxy) GetString(key string) string {
+ vp.Lock()
+ defer vp.Unlock()
+ return vp.Viper.GetString(key)
+}
+
+func (vp *ViperProxy) GetBool(key string) bool {
+ vp.Lock()
+ defer vp.Unlock()
+ return vp.Viper.GetBool(key)
+}
+
+func (vp *ViperProxy) GetInt(key string) int {
+ vp.Lock()
+ defer vp.Unlock()
+ return vp.Viper.GetInt(key)
+}
+
+func (vp *ViperProxy) GetStringSlice(key string) []string {
+ vp.Lock()
+ defer vp.Unlock()
+ return vp.Viper.GetStringSlice(key)
+}
+
func GetViper() *ViperProxy {
v := &ViperProxy{}
v.Viper = viper.GetViper()