将nacos作为go的配置中心和注册中心
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
YoyoFx 14b8a67811
Merge pull request #1 from yoyofxteam/dev
notify event on remote config changed
3 years ago
.idea provider with config type 3 years ago
example notify event on remote config changed 3 years ago
LICENSE Create LICENSE 3 years ago
README.md Update README.md 3 years ago
config_remote_provider.go notify event on remote config changed 3 years ago
example_config.yaml Nacos AMC or KMS 3 years ago
go.mod Upgrade dependency for viper 1.8.1 3 years ago
nacos_manager.go Nacos AMC or KMS 3 years ago
nacos_options.go Nacos AMC or KMS 3 years ago
nacosprovider.go notify event on remote config changed 3 years ago
viper_manager.go nacos viper remote provider 3 years ago
viper_remote.go notify event on remote config changed 3 years ago

README.md

Viper remote for Nacos

Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs.

runtime_viper := viper.New()

remote.SetOptions(&remote.Option{
   Url:         "localhost",
   Port:        80,
   NamespaceId: "public",
   GroupName:   "DEFAULT_GROUP",
   Config: 	remote.Config{ DataId: "config_dev" },
   Auth:        nil,
})

err := remote_viper.AddRemoteProvider("nacos", "localhost", "")
remote_viper.SetConfigType("yaml")

_ = remote_viper.ReadRemoteConfig()             //sync get remote configs to remote_viper instance memory . for example , remote_viper.GetString(key)
_ = remote_viper.WatchRemoteConfigOnChannel()   //async watch , auto refresh configs.

appName := remote_viper.GetString("key")   // sync get config by key

fmt.Println(appName)