Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
59ac25d85d
27
README.md
27
README.md
@ -1 +1,26 @@
|
||||
# nacos-viper-remote
|
||||
# Viper remote for Nacos
|
||||
|
||||
Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs.
|
||||
|
||||
```go
|
||||
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)
|
||||
```
|
||||
|
@ -8,7 +8,7 @@ yoyogo:
|
||||
strategy: "round-robin" # round-robin , weight-time , random
|
||||
type: "nacos"
|
||||
metadata:
|
||||
url: "120.53.133.30"
|
||||
url: "localhost"
|
||||
port: 80
|
||||
namespace: "public"
|
||||
group: "DEFAULT_GROUP"
|
||||
@ -17,4 +17,4 @@ yoyogo:
|
||||
auth:
|
||||
enable: true
|
||||
username: "root"
|
||||
password: "1234"
|
||||
password: "1234"
|
||||
|
Loading…
Reference in New Issue
Block a user