From 8e0183a5964c276e60d535b06aa5afa5dab7bf9f Mon Sep 17 00:00:00 2001 From: YoyoFx Date: Thu, 29 Apr 2021 22:01:07 +0800 Subject: [PATCH 1/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c98505..5bc45e0 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# nacos-viper-remote \ No newline at end of file +# nacos-viper-remote + +Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs. From a2e5f498571340cd5b1f68bee2836db9b2e963c8 Mon Sep 17 00:00:00 2001 From: YoyoFx Date: Thu, 29 Apr 2021 22:07:32 +0800 Subject: [PATCH 2/5] Update README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 5bc45e0..e0d03e2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,26 @@ # nacos-viper-remote 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") + + fmt.Println(appName) +``` From 1b743869b2a4ef7c6c19607253b8db54123babe2 Mon Sep 17 00:00:00 2001 From: YoyoFx Date: Thu, 29 Apr 2021 22:09:10 +0800 Subject: [PATCH 3/5] Update README.md --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e0d03e2..1ab3ded 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,24 @@ Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs. ```go - runtime_viper := viper.New() +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, - }) +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") +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. +_ = 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") +appName := remote_viper.GetString("key") // sync get config by key - fmt.Println(appName) +fmt.Println(appName) ``` From a518073e67a87a4ab49a87445cc0324314421477 Mon Sep 17 00:00:00 2001 From: YoyoFx Date: Thu, 29 Apr 2021 22:13:55 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ab3ded..27370c1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# nacos-viper-remote +# Viper remote for Nacos Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs. From 39af901d9da9d3cbcecd0bd54db181cd818e5f6b Mon Sep 17 00:00:00 2001 From: YoyoFx Date: Fri, 30 Apr 2021 11:17:50 +0800 Subject: [PATCH 5/5] Update example_config.yaml --- example_config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example_config.yaml b/example_config.yaml index eb8fbd2..3de4f29 100644 --- a/example_config.yaml +++ b/example_config.yaml @@ -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" \ No newline at end of file + password: "1234"