All Projects → gogap → redconf

gogap / redconf

Licence: Apache-2.0 license
sync config from redis or others storage while the config values changed

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to redconf

Appconfiguration
Questions, feedback and samples for Azure App Configuration service
Stars: ✭ 116 (+866.67%)
Mutual labels:  config, configuration-management
superconfig
Access environment variables. Also includes presence validation, type coercion and default values.
Stars: ✭ 33 (+175%)
Mutual labels:  config, configuration-management
Config
Library for managing environment variables in Clojure using EDN configuration files
Stars: ✭ 125 (+941.67%)
Mutual labels:  config, configuration-management
Node No Config
Config and resource loader
Stars: ✭ 45 (+275%)
Mutual labels:  config, configuration-management
DazzleConf
Incredible configuration library
Stars: ✭ 34 (+183.33%)
Mutual labels:  config, configuration-management
Electrode Confippet
node.js environment aware application configuration
Stars: ✭ 109 (+808.33%)
Mutual labels:  config, configuration-management
Config
Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other Ruby projects.
Stars: ✭ 1,821 (+15075%)
Mutual labels:  config, configuration-management
Conf
Simple config handling for your app or module
Stars: ✭ 707 (+5791.67%)
Mutual labels:  config, configuration-management
juno-agent
juno-agent
Stars: ✭ 46 (+283.33%)
Mutual labels:  config, configuration-management
ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (+500%)
Mutual labels:  config, configuration-management
Configuration
Library for setting values to structs' fields from env, flags, files or default tag
Stars: ✭ 37 (+208.33%)
Mutual labels:  config, configuration-management
configster
Rust library for parsing configuration files
Stars: ✭ 19 (+58.33%)
Mutual labels:  config, configuration-management
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+7525%)
Mutual labels:  config, configuration-management
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+17250%)
Mutual labels:  config, configuration-management
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (+6866.67%)
Mutual labels:  config, configuration-management
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+15358.33%)
Mutual labels:  config, configuration-management
Koanf
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.
Stars: ✭ 450 (+3650%)
Mutual labels:  config, configuration-management
Ini Parser
Read/Write an INI file the easy way!
Stars: ✭ 643 (+5258.33%)
Mutual labels:  config, configuration-management
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+1275%)
Mutual labels:  config, configuration-management
sitri
Sitri - powerful settings & configs for python
Stars: ✭ 20 (+66.67%)
Mutual labels:  config, configuration-management

RedConf

Sync config from redis or others storages while the key's value changed

Usage

  • The following struct is the config what we want sync with storage while the values changed
type ServerConfig struct {
	Host     string
	Port     int
	AllowIPs []string
}

type LogConfig struct {
	Path    string
	Maxsize int
}

type AppConfig struct {
	Server ServerConfig
	Log    LogConfig
}
  • We need create storage for tell redconf where the config values stored, and create monitor to notify the redconf while the values changed
	opts = redconf.Options{
		"address":  "localhost:6379",
		"password": "",
		"db":       0,
		"idle":     10,
		"channel":  "ONCHANGED",
	}

	if monitor, err = redconf.CreateMonitor("redis", opts); err != nil {
		fmt.Println(err)
		return
	}

	if storage, err = redconf.CreateStorage("redis", opts); err != nil {
		fmt.Println(err)
		return
	}
  • Create RedConf instance and watch the config
	if redConf, err = redconf.New(namespace, storage, monitor); err != nil {
		return
	}

	appConf := AppConfig{}

	if err = redConf.Watch(&appConf); err != nil {
		fmt.Println(err)
		return
	}
  • Initial redis key-value
$> redis-cli
127.0.0.1:6379> SET GOGAP:AppConfig:Server:AllowIPs 127.0.0.1,202.10.5.123
OK
  • Run example code
$> go run example/*.go
  • Open new terminal session and change the config in redis
$> redis-cli
127.0.0.1:6379>SET GOGAP:AppConfig:Server:AllowIPs 127.0.0.1,202.10.5.125
OK
127.0.0.1:6379> PUBLISH ONCHANGED GOGAP:AppConfig:Server:AllowIPs
(integer) 1

Then you will see the change from your terminal

  • if you want subscribe the value change event, you could do as following:
func onValueChangedSubscriber(event redconf.OnValueChangedEvent) {
	var err error
	var data []byte
	if data, err = json.MarshalIndent(&event, "", "    "); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(data))
}


redConf.Subscribe(onValueChangedSubscriber)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].