Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Commit cb8f743

Browse files
authored
supported dubbo-go v3.0.2 (#49)
1 parent 47241c9 commit cb8f743

File tree

14 files changed

+647
-489
lines changed

14 files changed

+647
-489
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- { name: 'resty', plugin_dir: 'resty', go_version: '1.13' }
4040
- { name: 'go-restful', plugin_dir: 'go-restful', go_version: '1.13' }
4141
- { name: 'logrus', plugin_dir: 'logrus', go_version: '1.13' }
42-
- { name: 'dubbo-go', plugin_dir: 'dubbo-go', go_version: '1.14' }
42+
- { name: 'dubbo-go', plugin_dir: 'dubbo-go', go_version: '1.15' }
4343
- { name: 'grom', plugin_dir: 'grom', go_version: '1.16' }
4444
- { name: 'kafka-reporter', plugin_dir: 'kafkareporter', go_version: '1.16' }
4545
- { name: 'kratos', plugin_dir: 'kratos', go_version: '1.16' }

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ deps:
2727

2828
LINTER := bin/golangci-lint
2929
$(LINTER):
30-
curl -L https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.45.2
30+
curl -L https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2
3131

3232
.PHONY: lint
3333
lint: $(LINTER)

dubbo-go/README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
##### Installation
44

55
```
6-
go get -u github.com/SkyAMP/go2sky-plugins/dubbo-go
6+
go get -u github.com/SkyAPM/go2sky-plugins/dubbo-go
77
```
88

99
##### Usage
@@ -12,17 +12,11 @@ Server:
1212

1313
```go
1414
import (
15-
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
16-
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
1715
"dubbo.apache.org/dubbo-go/v3/common/logger"
18-
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
1916
"dubbo.apache.org/dubbo-go/v3/config"
20-
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
21-
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
22-
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
23-
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
2417
"github.com/SkyAPM/go2sky"
2518
"github.com/SkyAPM/go2sky/reporter"
19+
_ "dubbo.apache.org/dubbo-go/v3/imports"
2620
hessian "github.com/apache/dubbo-go-hessian2"
2721

2822
dubbo_go "github.com/SkyAPM/go2sky-plugins/dubbo-go"
@@ -58,14 +52,8 @@ Client:
5852

5953
```go
6054
import (
61-
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
62-
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
63-
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
6455
"dubbo.apache.org/dubbo-go/v3/config"
65-
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
66-
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
67-
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
68-
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
56+
_ "dubbo.apache.org/dubbo-go/v3/imports"
6957
"github.com/SkyAPM/go2sky"
7058
"github.com/SkyAPM/go2sky/reporter"
7159
hessian "github.com/apache/dubbo-go-hessian2"

dubbo-go/dubbo-go.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,18 @@ func (cf tracingFilter) Invoke(ctx context.Context, invoker protocol.Invoker, in
125125

126126
if cf.side == clientSide {
127127
span, _ = cf.tracer.CreateExitSpan(ctx, operationName, invoker.GetURL().Location, func(key, value string) error {
128-
invocation.SetAttachments(key, value)
128+
invocation.SetAttachment(key, value)
129129
return nil
130130
})
131131

132132
span.SetComponent(componentID)
133133
} else {
134134
// componentIDGo2SkyServer
135135
span, ctx, _ = cf.tracer.CreateEntrySpan(ctx, operationName, func(key string) (string, error) {
136-
return invocation.AttachmentsByKey(key, ""), nil
136+
if attachment, ok := invocation.GetAttachment(key); ok {
137+
return attachment, nil
138+
}
139+
return "", nil
137140
})
138141

139142
span.SetComponent(componentID)

dubbo-go/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/SkyAPM/go2sky-plugins/dubbo-go
22

3-
go 1.14
3+
go 1.15
44

55
require (
6-
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2
6+
dubbo.apache.org/dubbo-go/v3 v3.0.2
77
github.com/SkyAPM/go2sky v1.4.1
8-
github.com/apache/dubbo-go-hessian2 v1.9.3
9-
github.com/dubbogo/gost v1.11.17
8+
github.com/apache/dubbo-go-hessian2 v1.11.0
9+
github.com/dubbogo/gost v1.11.25
1010
skywalking.apache.org/repo/goapi v0.0.0-20220401015832-2c9eee9481eb
1111
)

dubbo-go/go.sum

Lines changed: 478 additions & 297 deletions
Large diffs are not rendered by default.

dubbo-go/test/client/cmd/client.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@ import (
2222
"net/http"
2323
"time"
2424

25-
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
26-
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
27-
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
2825
"dubbo.apache.org/dubbo-go/v3/config"
29-
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
30-
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
31-
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
32-
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
26+
_ "dubbo.apache.org/dubbo-go/v3/imports"
3327
"github.com/SkyAPM/go2sky"
3428
"github.com/SkyAPM/go2sky/reporter"
3529
hessian "github.com/apache/dubbo-go-hessian2"
@@ -51,10 +45,13 @@ const (
5145
serviceName = "dubbo-go-client"
5246
)
5347

54-
// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run
48+
// need to setup environment variable "DUBBO_GO_CONFIG_PATH" to "conf/client.yml" before run
5549
func main() {
5650
hessian.RegisterPOJO(&pkg.User{})
57-
config.Load()
51+
err := config.Load()
52+
if err != nil {
53+
log.Fatalf("load config error: %v \n", err)
54+
}
5855
time.Sleep(3 * time.Second)
5956

6057
report, err := reporter.NewGRPCReporter(oap)
@@ -78,8 +75,9 @@ func main() {
7875
route := http.NewServeMux()
7976

8077
route.HandleFunc("/hello", func(writer http.ResponseWriter, req *http.Request) {
81-
user := &pkg.User{}
82-
err1 := userProvider.GetUser(req.Context(), []interface{}{"A001"}, user)
78+
var user *pkg.User
79+
var err1 error
80+
user, err1 = userProvider.GetUser(req.Context(), []interface{}{"A001"})
8381
if err1 != nil {
8482
writer.WriteHeader(http.StatusInternalServerError)
8583
_, _ = writer.Write([]byte(fmt.Sprintf("call service err %v \n", err1)))

dubbo-go/test/client/conf/client.yml

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,59 @@
1515
#
1616
# dubbo client yaml configure file
1717

18-
check: true
19-
# client
20-
request_timeout : "3s"
21-
# connect timeout
22-
connect_timeout : "3s"
23-
2418
# application config
25-
application:
26-
organization : "dubbo.io"
27-
name : "UserInfoClient"
28-
module : "dubbo-go user-info client"
29-
version : "0.0.1"
30-
environment : "dev"
31-
32-
# registry config
33-
registries :
34-
"demoZk":
35-
protocol: "zookeeper"
36-
timeout : "3s"
37-
address: "zookeeper:2181"
38-
username: ""
39-
password: ""
19+
dubbo:
20+
application:
21+
organization: "dubbo.io"
22+
name: "UserInfoClient"
23+
module: "dubbo-go user-info client"
24+
version: "0.0.1"
25+
environment: "dev"
4026

41-
# filter config
42-
filter: "go2sky-tracing-client"
27+
# registry config
28+
registries:
29+
demoZk:
30+
protocol: "zookeeper"
31+
timeout: "3s"
32+
address: "zookeeper:2181"
33+
username: ""
34+
password: ""
4335

44-
# reference config
45-
references:
46-
"UserProvider":
47-
registry: "demoZk"
48-
protocol : "dubbo"
49-
interface : "org.apache.dubbo.UserProvider"
50-
cluster: "failover"
51-
methods :
52-
- name: "GetUser"
53-
retries: 3
36+
# reference config
37+
consumer:
38+
check: true
39+
references:
40+
"UserProvider":
41+
protocol: "dubbo"
42+
interface: "org.apache.dubbo.UserProvider"
43+
# filter config
44+
filter: "go2sky-tracing-client"
45+
cluster: "failover"
46+
methods:
47+
-
48+
name: "GetUser"
49+
retries: 3
5450

55-
# protocol config
56-
protocol_conf:
57-
dubbo:
58-
reconnect_interval: 0
59-
connection_number: 1
60-
heartbeat_period: "5s"
61-
session_timeout: "180s"
62-
pool_size: 64
63-
pool_ttl: 600
64-
getty_session_param:
65-
compress_encoding: false
66-
tcp_no_delay: true
67-
tcp_keep_alive: true
68-
keep_alive_period: "120s"
69-
tcp_r_buf_size: 262144
70-
tcp_w_buf_size: 65536
71-
pkg_rq_size: 1024
72-
pkg_wq_size: 512
73-
tcp_read_timeout: "1s"
74-
tcp_write_timeout: "5s"
75-
wait_timeout: "1s"
76-
max_msg_len: 1024000
77-
session_name: "client"
51+
# protocol config
52+
protocols:
53+
"dubbo":
54+
params:
55+
"dubbo":
56+
reconnect_interval: 0
57+
connection_number: 1
58+
heartbeat_period: "5s"
59+
session_timeout: "180s"
60+
pool_size: 64
61+
pool_ttl: 600
62+
getty_session_param:
63+
compress_encoding: false
64+
tcp_no_delay: true
65+
tcp_keep_alive: true
66+
keep_alive_period: "120s"
67+
tcp_r_buf_size: 262144
68+
tcp_w_buf_size: 65536
69+
tcp_read_timeout: "1s"
70+
tcp_write_timeout: "5s"
71+
wait_timeout: "1s"
72+
max_msg_len: 1024000
73+
session_name: "client"

dubbo-go/test/client/pkg/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type User struct {
3131

3232
// UserProvider user provider service
3333
type UserProvider struct {
34-
GetUser func(ctx context.Context, req []interface{}, rsp *User) error
34+
GetUser func(ctx context.Context, req []interface{}) (*User, error)
3535
}
3636

3737
// Reference rpc service id or reference id

dubbo-go/test/docker/Dockerfile.client

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
# limitations under the License.
1515
#
1616

17-
FROM golang:1.14
17+
FROM golang:1.15
1818

1919
ADD ./dubbo-go /dubbo-go
2020
WORKDIR /dubbo-go
2121

2222
ENV APP_LOG_CONF_FILE /dubbo-go/test/client/conf/log.yml
23-
ENV CONF_CONSUMER_FILE_PATH /dubbo-go/test/client/conf/client.yml
23+
ENV DUBBO_GO_CONFIG_PATH /dubbo-go/test/client/conf/client.yml
2424

2525
EXPOSE 8080
2626

0 commit comments

Comments
 (0)