FinalT commented on code in PR #709:
URL: https://github.com/apache/dubbo-go-samples/pull/709#discussion_r1519688297


##########
integrate_test/config_center/nacos/tests/integration/main_test.go:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/nacos/proto"
+       "os"
+       "testing"
+       "time"
+)

Review Comment:
   ditto.



##########
config_center/zookeeper/go-client/cmd/main.go:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/zookeeper/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"

Review Comment:
   ditto.



##########
integrate_test/config_center/nacos/tests/integration/config_center_nacos_test.go:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+       "context"
+       greet "github.com/apache/dubbo-go-samples/config_center/nacos/proto"
+       "github.com/stretchr/testify/assert"
+       "testing"
+)

Review Comment:
   ditto.



##########
config_center/nacos/README.md:
##########
@@ -0,0 +1,68 @@
+# Dubbo-go Config-Center Sample
+
+## 1. Introduction
+
+This example shows dubbo-go's dynamic configuration feature with Nacos as 
config-center.
+
+## 2. How to run
+
+### Add configuration to the configuration center of nacos
+
+```go
+dynamicConfig, err := config.NewConfigCenterConfigBuilder().
+SetProtocol("nacos").
+SetAddress("127.0.0.1:8848").
+Build().GetDynamicConfiguration()
+
+if err != nil {
+    panic(err)
+}
+
+if err := 
dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-nacos-server", 
"dubbo", configCenterNacosServerConfig); err != nil {
+    panic(err)
+}
+time.Sleep(time.Second * 10)
+```
+Open `https://localhost:8848/nacos/` with browser, make sure the relevant 
configuration is already in place in nacos.

Review Comment:
   I think just introduce the configuration in the config center, and how to 
use it.



##########
config_center/zookeeper/README.md:
##########
@@ -0,0 +1,68 @@
+# Dubbo-go Config-Center Sample
+
+## 1. Introduction
+
+This example shows dubbo-go's dynamic configuration feature with Zookeeper as 
config-center.
+
+## 2. How to run
+
+### Add configuration to the configuration center of zookeeper
+
+```go
+dynamicConfig, err := config.NewConfigCenterConfigBuilder().
+SetProtocol("zookeeper").
+SetAddress("127.0.0.1:2181").
+Build().GetDynamicConfiguration()
+if err != nil {
+    panic(err)
+}
+
+if err := 
dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-zookeeper-server", 
"dubbogo", configCenterZKServerConfig); err != nil {
+    panic(err)
+}
+time.Sleep(time.Second * 10)
+```

Review Comment:
   ditto.



##########
config_center/nacos/go-client/cmd/main.go:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/nacos/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"
+)
+
+const configCenterNacosClientConfig = `## set in config center, group is 
'dubbo', dataid is 'dubbo-go-samples-configcenter-nacos-client', namespace is 
default
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
+  consumer:
+    references:
+      GreeterClientImpl:
+        protocol: tri
+        interface: com.apache.dubbo.sample.basic.IGreeter 
+`
+
+func main() {
+       dynamicConfig, err := config.NewConfigCenterConfigBuilder().
+               SetProtocol("nacos").
+               SetAddress("127.0.0.1:8848").
+               Build().GetDynamicConfiguration()
+       if err != nil {
+               panic(err)
+       }
+       if err = 
dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-nacos-client", 
"dubbo", configCenterNacosClientConfig); err != nil {
+               panic(err)
+       }

Review Comment:
   It would be better to use the `nacos-sdk-go` directly, as we plan to remove 
the `config` package in the future



##########
integrate_test/helloworld/tests/integration/main_test.go:
##########
@@ -18,13 +18,11 @@
 package integration
 
 import (
+       "dubbo.apache.org/dubbo-go/v3/client"
+       greet "github.com/apache/dubbo-go-samples/helloworld/proto"
        "os"
        "testing"
 
-       greet "github.com/apache/dubbo-go-samples/helloworld/proto"
-
-       "dubbo.apache.org/dubbo-go/v3/client"
-
        _ "dubbo.apache.org/dubbo-go/v3/imports"
 )

Review Comment:
   ditto.



##########
config_center/nacos/go-server/cmd/main.go:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/nacos/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"
+)
+
+type GreetTripleServer struct {
+}
+
+func (srv *GreetTripleServer) Greet(ctx context.Context, req 
*greet.GreetRequest) (*greet.GreetResponse, error) {
+       resp := &greet.GreetResponse{Greeting: req.Name}
+       return resp, nil
+}
+
+const configCenterNacosServerConfig = `## set in config center, group is 
'dubbo', dataid is 'dubbo-go-samples-configcenter-nacos-server', namespace is 
default
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 3s
+      address: '127.0.0.1:2181'
+  protocols:
+    triple:
+      name: tri
+      port: 20000
+  provider:
+    services:
+      GreeterProvider:
+        interface: com.apache.dubbo.sample.basic.IGreeter
+`
+
+func main() {
+       dynamicConfig, err := config.NewConfigCenterConfigBuilder().
+               SetProtocol("nacos").
+               SetAddress("127.0.0.1:8848").
+               Build().GetDynamicConfiguration()
+
+       if err != nil {
+               panic(err)
+       }
+
+       if err = 
dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-nacos-server", 
"dubbo", configCenterNacosServerConfig); err != nil {
+               panic(err)
+       }
+       time.Sleep(time.Second * 10)

Review Comment:
   ditto.



##########
integrate_test/config_center/zookeeper/tests/integration/main_test.go:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/zookeeper/proto"
+       "os"
+       "testing"
+       "time"
+)

Review Comment:
   ditto.



##########
config_center/nacos/go-server/cmd/main.go:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/nacos/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"

Review Comment:
   ditto.



##########
config_center/zookeeper/go-server/cmd/main.go:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/zookeeper/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"
+)

Review Comment:
   ditto.



##########
integrate_test/config_center/zookeeper/tests/integration/config_center_nacos_test.go:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+       "context"
+       greet "github.com/apache/dubbo-go-samples/config_center/zookeeper/proto"
+       "github.com/stretchr/testify/assert"
+       "testing"
+)

Review Comment:
   ditto.



##########
config_center/nacos/go-client/cmd/main.go:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/nacos/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"

Review Comment:
   plz format imports



##########
config_center/zookeeper/go-server/cmd/main.go:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/zookeeper/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"
+)
+
+type GreetTripleServer struct {
+}
+
+func (srv *GreetTripleServer) Greet(ctx context.Context, req 
*greet.GreetRequest) (*greet.GreetResponse, error) {
+       resp := &greet.GreetResponse{Greeting: req.Name}
+       return resp, nil
+}
+
+const configCenterZKServerConfig = `## set in config center, group is 
'dubbogo', dataid is 'dubbo-go-samples-configcenter-zookeeper-server', 
namespace is default
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 3s
+      address: '127.0.0.1:2181'
+  protocols:
+    triple:
+      name: tri
+      port: 20000
+  provider:
+    services:
+      GreeterProvider:
+        interface: com.apache.dubbo.sample.basic.IGreeter
+`
+
+func main() {
+       dynamicConfig, err := config.NewConfigCenterConfigBuilder().
+               SetProtocol("zookeeper").
+               SetAddress("127.0.0.1:2181").
+               Build().GetDynamicConfiguration()
+       if err != nil {
+               panic(err)
+       }
+
+       if err = 
dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-zookeeper-server", 
"dubbogo", configCenterZKServerConfig); err != nil {
+               panic(err)
+       }
+       time.Sleep(time.Second * 10)

Review Comment:
   ditto.



##########
config_center/zookeeper/go-client/cmd/main.go:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       greet "github.com/apache/dubbo-go-samples/config_center/zookeeper/proto"
+       "github.com/dubbogo/gost/log/logger"
+       "time"
+)
+
+const configCenterZKClientConfig = `## set in config center, group is 
'dubbogo', dataid is 'dubbo-go-samples-configcenter-zookeeper-client', 
namespace is default
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
+  consumer:
+    references:
+      GreeterClientImpl:
+        protocol: tri
+        interface: com.apache.dubbo.sample.basic.IGreeter 
+`
+
+func main() {
+       dynamicConfig, err := config.NewConfigCenterConfigBuilder().
+               SetProtocol("zookeeper").
+               SetAddress("127.0.0.1:2181").
+               Build().GetDynamicConfiguration()
+       if err != nil {
+               panic(err)
+       }
+       if err = 
dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-zookeeper-client", 
"dubbogo", configCenterZKClientConfig); err != nil {
+               panic(err)
+       }
+
+       time.Sleep(time.Second * 10)

Review Comment:
   ditto.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to