github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/viperx/doc.go (about) 1 /* 2 Copyright (C) 2022-2023 ApeCloud Co., Ltd 3 4 This file is part of KubeBlocks project 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU Affero General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 // Package viperx is a thread-safe extension for the Viper configuration library. 21 // 22 // # Overview 23 // 24 // The viperx package provides a set of utilities and enhancements to the Viper library 25 // that ensure thread-safety when working with configuration settings in concurrent 26 // environments. 27 // 28 // # Features 29 // 30 // - Thread-safe access: All operations on the configuration settings are designed to be 31 // safe for concurrent access from multiple goroutines. 32 // 33 // - Locking mechanism: The package utilizes a mutex lock to protect concurrent read 34 // and write operations on the underlying Viper configuration. 35 // 36 // # Usage 37 // 38 // To use viperx, import the package and call viperx.XXX where supposed to call viper.XXX. 39 // Or, import the package and set the alias to viper, all viper calls exist should work well. 40 // 41 // Example: 42 // 43 // import "github.com/1aal/kubeblocks/pkg/viperx" 44 // 45 // func main() { 46 // // Set a configuration value 47 // viperx.Set("key", "value") 48 // 49 // // Get a configuration value 50 // val := viperx.Get("key") 51 // fmt.Println(val) 52 // } 53 // 54 // Note: While ViperX ensures thread-safety for the configuration settings, it does not 55 // modify the underlying behavior of Viper itself. It is still important to follow the 56 // guidelines and best practices provided by Viper for configuration management. 57 // 58 // For more information on Viper, refer to the official Viper documentation at: 59 // https://github.com/spf13/viper 60 package viperx