You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/10/22 11:58:55 UTC

[dubbo-go-samples] branch master updated: refactor: jsonrpc sample (#277)

This is an automated email from the ASF dual-hosted git repository.

laurence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new 8023b00  refactor: jsonrpc sample (#277)
8023b00 is described below

commit 8023b00df27e62fdff8ff3a8c8cace09d6d5b3f1
Author: phil <ph...@foxmail.com>
AuthorDate: Fri Oct 22 19:58:49 2021 +0800

    refactor: jsonrpc sample (#277)
    
    * refactor: jsonrpc sample
    
    * refactor: fmt
    
    * fix: remove qoute
    
    Co-authored-by: LaurenceLiZhixin <38...@qq.com>
---
 rpc/jsonrpc/go-client/conf/dubbogo.yml | 68 ++++++++++++---------------------
 rpc/jsonrpc/go-client/pkg/user.go      | 12 ------
 rpc/jsonrpc/go-server/conf/dubbogo.yml | 69 ++++++++++++----------------------
 3 files changed, 47 insertions(+), 102 deletions(-)

diff --git a/rpc/jsonrpc/go-client/conf/dubbogo.yml b/rpc/jsonrpc/go-client/conf/dubbogo.yml
index 2dff17d..57068e2 100644
--- a/rpc/jsonrpc/go-client/conf/dubbogo.yml
+++ b/rpc/jsonrpc/go-client/conf/dubbogo.yml
@@ -1,52 +1,32 @@
 dubbo:
   application:
-    organization: "dubbo.apache.org"
-    name: "UserInfoServer"
-    module: "dubbo-go user-info client"
-    version: "0.0.1"
-    environment: "dev"
+    organization: dubbo.apache.org
+    name: UserInfoServer
+    module: dubbo-go-user-info-client
+    version: 0.0.1
+    environment: dev
   registries:
-    "hangzhouzk":
-      protocol: "zookeeper"
-      timeout: "3s"
-      address: "127.0.0.1:2181"
-      username: ""
-      password: ""
-    "shanghaizk":
-      protocol: "zookeeper"
-      timeout: "3s"
-      address: "127.0.0.1:2182"
-      username: ""
-      password: ""
+    hangzhouzk:
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
   consumer:
     references:
-      "com.ikurento.user.UserProvider":
-        registryIDs: "hangzhouzk"
-        protocol: "jsonrpc"
-        interface: "com.ikurento.user.UserProvider"
-        cluster: "failover"
-        methods:
-          - name: "GetUser"
-            retries: 1
-      "com.ikurento.user.UserProvider1":
-        registryIDs: "hangzhouzk"
-        protocol: "jsonrpc"
-        version: "2.0"
-        interface: "com.ikurento.user.UserProvider"
-        cluster: "failover"
-        methods:
-          - name: "GetUser"
-            retries: 1
-      "com.ikurento.user.UserProvider2":
-        registryIDs: "hangzhouzk"
-        protocol: "jsonrpc"
-        version: "2.0"
-        group: "as"
-        interface: "com.ikurento.user.UserProvider"
-        cluster: "failover"
-        methods:
-          - name: "GetUser"
-            retries: 1
+      UserProvider:
+        registryIDs: hangzhouzk
+        protocol: jsonrpc
+        interface: com.ikurento.user.UserProvider
+      UserProvider1:
+        registryIDs: hangzhouzk
+        protocol: jsonrpc
+        version: 2.0
+        interface: com.ikurento.user.UserProvider
+      UserProvider2:
+        registryIDs: hangzhouzk
+        protocol: jsonrpc
+        version: 2.0"
+        group: as
+        interface: com.ikurento.user.UserProvider
   logger:
     zap-config:
       level: info
\ No newline at end of file
diff --git a/rpc/jsonrpc/go-client/pkg/user.go b/rpc/jsonrpc/go-client/pkg/user.go
index 471bb01..cf8c552 100644
--- a/rpc/jsonrpc/go-client/pkg/user.go
+++ b/rpc/jsonrpc/go-client/pkg/user.go
@@ -48,10 +48,6 @@ type UserProvider struct {
 	Echo     func(ctx context.Context, req string) (string, error) // Echo represent EchoFilter will be used
 }
 
-func (u *UserProvider) Reference() string {
-	return "com.ikurento.user.UserProvider"
-}
-
 type UserProvider1 struct {
 	GetUsers func(ids []interface{}) ([]*JsonRPCUser, error)
 	GetUser  func(ctx context.Context, id string) (*JsonRPCUser, error)
@@ -62,10 +58,6 @@ type UserProvider1 struct {
 	Echo     func(ctx context.Context, req string) (string, error) // Echo represent EchoFilter will be used
 }
 
-func (u *UserProvider1) Reference() string {
-	return "com.ikurento.user.UserProvider1"
-}
-
 type UserProvider2 struct {
 	GetUsers func(ids []interface{}) ([]*JsonRPCUser, error)
 	GetUser  func(ctx context.Context, id string) (*JsonRPCUser, error)
@@ -75,7 +67,3 @@ type UserProvider2 struct {
 	GetUser3 func() error
 	Echo     func(ctx context.Context, req string) (string, error) // Echo represent EchoFilter will be used
 }
-
-func (u *UserProvider2) Reference() string {
-	return "com.ikurento.user.UserProvider2"
-}
diff --git a/rpc/jsonrpc/go-server/conf/dubbogo.yml b/rpc/jsonrpc/go-server/conf/dubbogo.yml
index a10b283..2db62e9 100644
--- a/rpc/jsonrpc/go-server/conf/dubbogo.yml
+++ b/rpc/jsonrpc/go-server/conf/dubbogo.yml
@@ -1,62 +1,39 @@
 dubbo:
   application:
-    organization: "dubbo.apache.org"
-    name: "UserInfoServer"
-    module: "dubbo-go user-info server"
-    version: "0.0.1"
-    environment: "dev"
+    organization: dubbo.apache.org
+    name: UserInfoServer
+    module: dubbo-go-user-info-server
+    version: 0.0.1
+    environment: dev
   registries:
-    "hangzhouzk":
-      protocol: "zookeeper"
-      timeout: "3s"
-      address: "127.0.0.1:2181"
-      username: ""
-      password: ""
+    hangzhouzk:
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
   protocols:
     "jsonrpc":
-      name: "jsonrpc"
-      ip: "127.0.0.1"
+      name: jsonrpc
+      ip: 127.0.0.1
       port: 20001
   provider:
     registryIDs:
       - hangzhouzk
     services:
       UserProvider:
-        registryIDs: "hangzhouzk"
-        protocolIDs: "jsonrpc"
-        interface: "com.ikurento.user.UserProvider"
-        loadbalance: "random"
-        warmup: "100"
-        cluster: "failover"
-        methods:
-          - name: "GetUser"
-            retries: 1
-            loadbalance: "random"
+        registryIDs: hangzhouzk
+        protocolIDs: jsonrpc
+        interface: com.ikurento.user.UserProvider
       UserProvider1:
-        registryIDs: "hangzhouzk"
-        protocol: "jsonrpc"
-        interface: "com.ikurento.user.UserProvider"
-        loadbalance: "random"
-        version: "2.0"
-        warmup: "100"
-        cluster: "failover"
-        methods:
-          - name: "GetUser"
-            retries: 1
-            loadbalance: "random"
+        registryIDs: hangzhouzk
+        protocolIDs: jsonrpc
+        interface: com.ikurento.user.UserProvider
+        version: 2.0
       UserProvider2:
-        registryIDs: "hangzhouzk"
-        protocol: "jsonrpc"
-        interface: "com.ikurento.user.UserProvider"
-        loadbalance: "random"
-        version: "2.0"
-        group: "as"
-        warmup: "100"
-        cluster: "failover"
-        methods:
-          - name: "GetUser"
-            retries: 1
-            loadbalance: "random"
+        registryIDs: hangzhouzk
+        protocolIDs: jsonrpc
+        interface: com.ikurento.user.UserProvider
+        version: 2.0
+        group: as
   logger:
     zap-config:
       level: info
\ No newline at end of file