Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

avoid viper concurrent access

Chris Lu819a85f59aad
diff --git a/weed/util/config.go b/weed/util/config.go
index 54edf5a3c9..e746b0bd19 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()