You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/02 05:33:04 UTC

[GitHub] [dubbo-go-samples] xavier-niu commented on a change in pull request #216: Ftr/direct samples

xavier-niu commented on a change in pull request #216:
URL: https://github.com/apache/dubbo-go-samples/pull/216#discussion_r700754527



##########
File path: direct/go-client/cmd/client.go
##########
@@ -19,51 +19,36 @@ package main
 
 import (
 	"context"
-	"os"
 	"time"
 )
 
 import (
-	_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
-	_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
-	_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
+	"dubbo.apache.org/dubbo-go/v3/common/logger"
 	"dubbo.apache.org/dubbo-go/v3/config"
-	_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
-	_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
-	_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
-	_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
-
-	hessian "github.com/apache/dubbo-go-hessian2"
-
-	"github.com/dubbogo/gost/log"
+	_ "dubbo.apache.org/dubbo-go/v3/imports"
 )
 
 import (
-	"github.com/apache/dubbo-go-samples/direct/go-client/pkg"
+	"github.com/apache/dubbo-go-samples/api"
 )
 
-var userProvider = new(pkg.UserProvider)
-
-func init() {
-	config.SetConsumerService(userProvider)
-	hessian.RegisterPOJO(&pkg.User{})
-}
+var grpcGreeterImpl = new(api.GreeterClientImpl)
 
-// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run
-// in order to make sure direct-invoking is enabled, check if references -> UserProvider -> url is specified
-// in conf/client.yaml
+// export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/helloworld/go-client/conf/dubbogo.yml
 func main() {
-	hessian.RegisterPOJO(&pkg.User{})
-	config.Load()
+	config.SetConsumerService(grpcGreeterImpl)
+	if err := config.Load(); err != nil{
+		panic(err)
+	}
 	time.Sleep(3 * time.Second)
 
-	gxlog.CInfo("\n\n\nstart to test dubbo")
-	user := &pkg.User{}
-	err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
+	logger.Info("start to test dubbo")
+	req := &api.HelloRequest{
+		Name: "laurence",
+	}
+	reply, err := grpcGreeterImpl.SayHello(context.Background(), req)
 	if err != nil {
-		gxlog.CError("error: %v\n", err)
-		os.Exit(1)
-		return
+		logger.Error(err)
 	}
-	gxlog.CInfo("response result: %v\n", user)
+	logger.Infof("client response result: %v\n", reply)

Review comment:
       Is this `\n` useful?

##########
File path: direct/go-client/conf/dubbogo.yml
##########
@@ -0,0 +1,7 @@
+dubbo:
+  consumer:
+    references:
+      "greeterImpl":
+        url: tri://localhost:20000
+        protocol: "tri"
+        interface: "com.apache.dubbo.sample.basic.IGreeter" # must be compatible with grpc or dubbo-java

Review comment:
       Quotations should be deleted in yml files

##########
File path: integrate_test/rpc/codec-extension/conf/dubbogo.yml
##########
@@ -0,0 +1,17 @@
+dubbo:
+  registries:
+    "demoZK":
+      protocol: "zookeeper"
+      timeout: "3s"
+      address: "127.0.0.1:2181"
+  protocols:
+    "triple":
+      name: "tri"
+      port: 20000
+  provider:
+    registry:
+      - demoZK
+    services:
+      "greeterImpl":
+        protocol: "triple"
+        interface: "com.apache.dubbo.sample.basic.IGreeter" # must be compatible with grpc or dubbo-java

Review comment:
       quotations

##########
File path: direct/go-server/conf/dubbogo.yml
##########
@@ -0,0 +1,10 @@
+dubbo:
+  protocols:
+    "triple":
+      name: "tri"
+      port: 20000
+  provider:
+    services:
+      "greeterImpl":
+        protocol: "triple"
+        interface: "com.apache.dubbo.sample.basic.IGreeter" # must be compatible with grpc or dubbo-java

Review comment:
       quotations




-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org