This is an automated email from the ASF dual-hosted git repository. zhaoyunxing pushed a commit to branch config-enhance in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
commit bfe39092d4617f64eb74edcbd5f3b759e8cc3c48 Author: Laurence <[email protected]> AuthorDate: Thu Sep 2 22:50:17 2021 +0800 Ftr/direct samples (#216) * feat: add triple codec-extension samples of v3 conig * fix: update client interface * fix: add direct samples and ci test * fix: delete unused merged file * fix: add integrate test --- .run/direct-go-client.run.xml | 7 +- .run/direct-go-server.run.xml | 15 ---- .run/helloworld-go-client.run.xml | 14 ---- .run/triple-codec-extension-client.run.xml | 15 ---- .run/triple-codec-extension-server.run.xml | 15 ---- .run/{triple => }/triplego-hessian-server.run.xml | 0 api/generate.sh | 2 +- configcenter/apollo/go-client/cmd/client.go | 4 +- direct/go-client/cmd/client.go | 47 ++++------- direct/go-client/conf/client.yml | 28 ------- direct/go-client/conf/dubbogo.yml | 7 ++ direct/go-client/conf/log.yml | 28 ------- direct/go-client/pkg/user.go | 42 ---------- direct/go-server/cmd/server.go | 59 ++++--------- direct/go-server/conf/client.yml | 61 -------------- direct/go-server/conf/dubbogo.yml | 10 +++ direct/go-server/conf/log.yml | 28 ------- direct/go-server/conf/server.yml | 54 ------------ direct/go-server/pkg/user.go | 62 -------------- direct/go-server/tests/integration/main_test.go | 71 ---------------- .../tests/integration/userprovider_test.go | 39 --------- go.mod | 6 +- go.sum | 7 ++ helloworld/go-client/cmd/client.go | 9 +- helloworld/go-server/conf/dubbogo.yml | 12 +-- .../integration/configapi_rpc_triple_test.go} | 11 +-- .../rpc/triple/tests/integration/main_test.go | 40 +++++---- .../tests/integration/greeterProvider_test.go | 9 +- .../apollo/tests/integration/main_test.go | 2 - .../nacos/tests/integration/main_test.go | 8 +- .../nacos/tests/integration/userprovider_test.go | 5 +- .../direct}/docker/docker-compose.yml | 0 .../direct}/docker/docker-health-check.sh | 0 .../tests/integration/main_test.go | 2 - .../tests/integration/userprovider_test.go | 3 - .../helloworld/docker/docker-compose.yml~merged | 9 -- .../tests/integration/helloworld_test.go} | 5 +- .../helloworld/tests/integration/main_test.go | 2 - .../zookeeper/docker/docker-compose.yml~merged | 9 -- .../zookeeper/docker/docker-health-check.sh~merged | 10 --- .../tests/integration/helloworld_test.go} | 3 - .../zookeeper/tests/integration/main_test.go | 31 ++----- .../tests/integration/userprovider_test.go | 39 --------- .../codec-extension}/docker/docker-compose.yml | 0 .../codec-extension}/docker/docker-health-check.sh | 0 .../codec-extension}/tests/integration/codec.go | 0 .../tests/integration/main_test.go | 4 +- .../tests/integration/userprovider_test.go | 7 +- .../rpc/{ => dubbo3}/hessian2/conf/client.yml | 0 .../rpc/dubbo3/hessian2}/conf/log.yml | 0 .../rpc/{ => dubbo3}/hessian2/conf/server.yml | 0 .../rpc/dubbo3/hessian2}/docker/docker-compose.yml | 0 .../dubbo3/hessian2}/docker/docker-health-check.sh | 0 .../hessian2/tests/integration/main_test.go | 13 +-- .../tests/integration/userprovider_test.go | 5 +- integrate_test/rpc/hessian2/conf/log.yml | 27 ------ .../rpc/hessian2/docker/docker-compose.yml~merged | 9 -- rpc/dubbo/go-client/cmd/client.go | 2 +- rpc/dubbo/go-server/cmd/server.go | 2 +- .../go-server/docker/docker-compose.yml~merged | 9 -- .../go-server/docker/docker-health-check.sh~merged | 10 --- .../tests/integration/userprovider_test.go | 2 +- .../codec-extension/{go-server => }/codec/codec.go | 0 rpc/dubbo3/codec-extension/go-client/cmd/client.go | 46 +++++----- .../codec-extension/go-client/codec/codec.go | 28 ------- .../codec-extension/go-client/conf/client.yml | 33 -------- .../codec-extension/go-client/conf/dubbogo.yml | 12 +++ rpc/dubbo3/codec-extension/go-client/conf/log.yml | 27 ------ rpc/dubbo3/codec-extension/go-client/pkg/hello.go | 36 -------- rpc/dubbo3/codec-extension/go-server/cmd/server.go | 97 ++++++++-------------- .../codec-extension/go-server/conf/client.yml | 32 ------- .../codec-extension/go-server/conf/dubbogo.yml | 17 ++++ .../codec-extension/go-server/conf/server.yml | 30 ------- .../go-server/docker/docker-compose.yml~merged | 9 -- .../codec-extension/go-server/pkg/greeter.go | 46 ---------- .../hessian2/go-server/cmd/simple_service.go | 2 +- rpc/dubbo3/msgpack/go-server/cmd/server.go | 6 +- .../server/dubbogo-server/cmd/server.go | 2 +- .../docker/docker-compose.yml~merged | 9 -- .../pb/dubbogo-grpc/server/grpcgo-server/main.go | 1 - .../go-server/docker/docker-compose.yml~merged | 9 -- rpc/grpc/go-client/cmd/client.go | 3 +- rpc/grpc/go-client/conf/log.yml~merged | 27 ------ rpc/grpc/go-server/conf/log.yml~merged | 27 ------ .../go-client/docker/docker-compose.yml~merged | 9 -- .../go-server/docker/docker-compose.yml~merged | 9 -- start_integrate_test.sh | 8 +- tracing/grpc/go-server/app/helloworld.pb.go | 2 - 88 files changed, 217 insertions(+), 1230 deletions(-) diff --git a/.run/direct-go-client.run.xml b/.run/direct-go-client.run.xml index 3cde22b..b248033 100644 --- a/.run/direct-go-client.run.xml +++ b/.run/direct-go-client.run.xml @@ -1,15 +1,14 @@ <component name="ProjectRunConfigurationManager"> - <configuration default="false" name="direct-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false"> + <configuration default="false" name="direct-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="true"> <module name="dubbo-go-samples" /> <working_directory value="$PROJECT_DIR$" /> <envs> - <env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/direct/go-client/conf/log.yml" /> - <env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/direct/go-client/conf/client.yml" /> + <env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/direct/go-client/conf/dubbogo.yml" /> </envs> <kind value="PACKAGE" /> - <filePath value="$PROJECT_DIR$/direct/go-client/cmd/client.go" /> <package value="github.com/apache/dubbo-go-samples/direct/go-client/cmd" /> <directory value="$PROJECT_DIR$" /> + <filePath value="$PROJECT_DIR$/direct/go-client/cmd/client.go" /> <method v="2" /> </configuration> </component> \ No newline at end of file diff --git a/.run/direct-go-server.run.xml b/.run/direct-go-server.run.xml deleted file mode 100644 index 621cbd1..0000000 --- a/.run/direct-go-server.run.xml +++ /dev/null @@ -1,15 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="direct-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false"> - <module name="dubbo-go-samples" /> - <working_directory value="$PROJECT_DIR$" /> - <envs> - <env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/direct/go-server/conf/server.yml" /> - <env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/direct/go-server/conf/log.yml" /> - </envs> - <kind value="PACKAGE" /> - <filePath value="$PROJECT_DIR$/direct/go-server/cmd/server.go" /> - <package value="github.com/apache/dubbo-go-samples/direct/go-server/cmd" /> - <directory value="$PROJECT_DIR$" /> - <method v="2" /> - </configuration> -</component> \ No newline at end of file diff --git a/.run/helloworld-go-client.run.xml b/.run/helloworld-go-client.run.xml deleted file mode 100644 index 05170fc..0000000 --- a/.run/helloworld-go-client.run.xml +++ /dev/null @@ -1,14 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="helloworld-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="v3config-helloworld" singleton="true"> - <module name="dubbo-go-samples" /> - <working_directory value="$PROJECT_DIR$" /> - <envs> - <env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/helloworld/go-client/conf/dubbogo.yml" /> - </envs> - <kind value="PACKAGE" /> - <package value="github.com/apache/dubbo-go-samples/helloworld/go-client/cmd" /> - <directory value="$PROJECT_DIR$" /> - <filePath value="$PROJECT_DIR$/helloworld/go-client/cmd/client.go" /> - <method v="2" /> - </configuration> -</component> \ No newline at end of file diff --git a/.run/triple-codec-extension-client.run.xml b/.run/triple-codec-extension-client.run.xml deleted file mode 100644 index ec0f339..0000000 --- a/.run/triple-codec-extension-client.run.xml +++ /dev/null @@ -1,15 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="triple-codec-extension-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="triple"> - <module name="dubbo-go-samples" /> - <working_directory value="$PROJECT_DIR$" /> - <envs> - <env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/general/dubbo3/codec-extension/go-client/conf/log.yml" /> - <env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/general/dubbo3/codec-extension/go-client/conf/client.yml" /> - </envs> - <kind value="PACKAGE" /> - <package value="github.com/apache/dubbo-go-samples/rpc/dubbo3/codec-extension/go-client/cmd" /> - <directory value="github.com/apache/dubbo-go-samples/general/dubbo3/api/dubbogo-grpc/server/dubbogo-server/cmd" /> - <filePath value="$PROJECT_DIR$" /> - <method v="2" /> - </configuration> -</component> \ No newline at end of file diff --git a/.run/triple-codec-extension-server.run.xml b/.run/triple-codec-extension-server.run.xml deleted file mode 100644 index da9aa95..0000000 --- a/.run/triple-codec-extension-server.run.xml +++ /dev/null @@ -1,15 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="triple-codec-extension-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="triple"> - <module name="dubbo-go-samples" /> - <working_directory value="$PROJECT_DIR$" /> - <envs> - <env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/general/dubbo3/codec-extension/go-server/conf/log.yml" /> - <env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/general/dubbo3/codec-extension/go-server/conf/server.yml" /> - </envs> - <kind value="PACKAGE" /> - <package value="github.com/apache/dubbo-go-samples/rpc/dubbo3/codec-extension/go-server/cmd" /> - <directory value="github.com/apache/dubbo-go-samples/general/dubbo3/api/dubbogo-grpc/server/dubbogo-server/cmd" /> - <filePath value="$PROJECT_DIR$" /> - <method v="2" /> - </configuration> -</component> \ No newline at end of file diff --git a/.run/triple/triplego-hessian-server.run.xml b/.run/triplego-hessian-server.run.xml similarity index 100% rename from .run/triple/triplego-hessian-server.run.xml rename to .run/triplego-hessian-server.run.xml diff --git a/api/generate.sh b/api/generate.sh index d116f65..23c7b71 100644 --- a/api/generate.sh +++ b/api/generate.sh @@ -1,4 +1,4 @@ export GO111MODULE="on" export GOPROXY="http://goproxy.io" -go get -u github.com/apache/dubbo-go/protocol/dubbo3/[email protected] +go get -u github.com/dubbogo/tools/cmd/[email protected] protoc -I . samples_api.proto --dubbo3_out=plugins=grpc+dubbo:. \ No newline at end of file diff --git a/configcenter/apollo/go-client/cmd/client.go b/configcenter/apollo/go-client/cmd/client.go index 68fe2c0..2c0c7ad 100644 --- a/configcenter/apollo/go-client/cmd/client.go +++ b/configcenter/apollo/go-client/cmd/client.go @@ -47,8 +47,8 @@ func main() { req := &api.HelloRequest{ Name: "laurence", } - reply := &api.User{} - if err := grpcGreeterImpl.SayHello(context.Background(), req, reply); err != nil { + reply, err := grpcGreeterImpl.SayHello(context.Background(), req) + if err != nil { logger.Error(err) } logger.Infof("client response result: %v\n", reply) diff --git a/direct/go-client/cmd/client.go b/direct/go-client/cmd/client.go index dd4c3f4..59596d6 100644 --- a/direct/go-client/cmd/client.go +++ b/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) } diff --git a/direct/go-client/conf/client.yml b/direct/go-client/conf/client.yml deleted file mode 100644 index 97863f5..0000000 --- a/direct/go-client/conf/client.yml +++ /dev/null @@ -1,28 +0,0 @@ -# dubbo client yaml configure file - -check: false -# client -request_timeout: "3s" -# connect timeout -connect_timeout: "3s" - -# application config -application: - organization: "dubbo.io" - name: "UserInfoClient" - module: "dubbo-go user-info client" - version: "0.0.1" - environment: "dev" - -# reference config -references: - "UserProvider": - registry: "demoZk" - protocol: "dubbo" - interface: "org.apache.dubbo.UserProvider" - cluster: "failover" - # this is necessary to enable direct-invoking. - url: "dubbo://127.0.0.1:20000" - methods: - - name: "GetUser" - retries: 3 \ No newline at end of file diff --git a/direct/go-client/conf/dubbogo.yml b/direct/go-client/conf/dubbogo.yml new file mode 100644 index 0000000..e4c8bb9 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/direct/go-client/conf/log.yml b/direct/go-client/conf/log.yml deleted file mode 100644 index d0400fe..0000000 --- a/direct/go-client/conf/log.yml +++ /dev/null @@ -1,28 +0,0 @@ - -level: "debug" -development: true -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capital" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/direct/go-client/pkg/user.go b/direct/go-client/pkg/user.go deleted file mode 100644 index 7733ea4..0000000 --- a/direct/go-client/pkg/user.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 pkg - -import ( - "context" - "time" -) - -type User struct { - ID string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (User) JavaClassName() string { - return "org.apache.dubbo.User" -} diff --git a/direct/go-server/cmd/server.go b/direct/go-server/cmd/server.go index c8c4c22..1514240 100644 --- a/direct/go-server/cmd/server.go +++ b/direct/go-server/cmd/server.go @@ -18,62 +18,33 @@ package main import ( - "fmt" - "os" - "os/signal" - "syscall" - "time" + "context" ) 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/logger" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "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" + _ "dubbo.apache.org/dubbo-go/v3/imports" ) import ( - "github.com/apache/dubbo-go-samples/direct/go-server/pkg" -) - -var ( - survivalTimeout = int(3e9) + "github.com/apache/dubbo-go-samples/api" ) -// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to "conf/server.yml" before run -func main() { - hessian.RegisterPOJO(&pkg.User{}) - config.Load() - - initSignal() +type GreeterProvider struct { + api.GreeterProviderBase } -func initSignal() { - signals := make(chan os.Signal, 1) - // It is not possible to block SIGKILL or syscall.SIGSTOP - signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) - for { - sig := <-signals - logger.Infof("get signal %s", sig.String()) - switch sig { - case syscall.SIGHUP: - // reload() - default: - time.AfterFunc(time.Duration(survivalTimeout), func() { - logger.Warnf("app exit now by force...") - os.Exit(1) - }) +func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { + logger.Infof("Dubbo3 GreeterProvider get user name = %s\n", in.Name) + return &api.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil +} - // The program exits normally or timeout forcibly exits. - fmt.Println("provider app exit now...") - return - } +// export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/helloworld/go-server/conf/dubbogo.yml +func main() { + config.SetProviderService(&GreeterProvider{}) + if err := config.Load(); err != nil { + panic(err) } + select {} } diff --git a/direct/go-server/conf/client.yml b/direct/go-server/conf/client.yml deleted file mode 100644 index 8823490..0000000 --- a/direct/go-server/conf/client.yml +++ /dev/null @@ -1,61 +0,0 @@ -# dubbo client yaml configure file - -check: true -# client -request_timeout : "3s" -# connect timeout -connect_timeout : "3s" - -# application config -application: - organization : "dubbo.io" - name : "UserConsumerTest" - module : "dubbo-go user-info client" - version : "0.0.1" - environment : "dev" - -# registry config -registries : - "demoZk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - -# reference config -references: - "UserProvider": - registry: "demoZk" - protocol : "dubbo" - interface : "org.apache.dubbo.UserProvider" - cluster: "failover" - # this is necessary to enable direct-invoking. - url: "dubbo://127.0.0.1:20000" - methods : - - name: "GetUser" - retries: 3 - -# protocol config -protocol_conf: - dubbo: - reconnect_interval: 0 - connection_number: 1 - heartbeat_period: "5s" - session_timeout: "180s" - pool_size: 64 - pool_ttl: 600 - getty_session_param: - compress_encoding: false - tcp_no_delay: true - tcp_keep_alive: true - keep_alive_period: "120s" - tcp_r_buf_size: 262144 - tcp_w_buf_size: 65536 - pkg_rq_size: 1024 - pkg_wq_size: 512 - tcp_read_timeout: "1s" - tcp_write_timeout: "5s" - wait_timeout: "1s" - max_msg_len: 1024000 - session_name: "client" diff --git a/direct/go-server/conf/dubbogo.yml b/direct/go-server/conf/dubbogo.yml new file mode 100644 index 0000000..f6551a9 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/direct/go-server/conf/log.yml b/direct/go-server/conf/log.yml deleted file mode 100644 index a75bccb..0000000 --- a/direct/go-server/conf/log.yml +++ /dev/null @@ -1,28 +0,0 @@ - -level: "error" -development: true -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capital" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/direct/go-server/conf/server.yml b/direct/go-server/conf/server.yml deleted file mode 100644 index 13b7f74..0000000 --- a/direct/go-server/conf/server.yml +++ /dev/null @@ -1,54 +0,0 @@ -# dubbo server yaml configure file -# application config -application: - organization : "dubbo.io" - name : "UserInfoServer" - module : "dubbo-go user-info server" - version : "0.0.1" - environment : "dev" - -# registry config -registries : - "demoZk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - -# service config -services: - "UserProvider": - registry: "demoZk" - protocol : "dubbo" - interface : "org.apache.dubbo.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 - loadbalance: "random" - -# protocol config -protocols: - "dubbo": - name: "dubbo" - port: 20000 - -protocol_conf: - dubbo: - session_number: 700 - session_timeout: "180s" - getty_session_param: - compress_encoding: false - tcp_no_delay: true - tcp_keep_alive: true - keep_alive_period: "120s" - tcp_r_buf_size: 262144 - tcp_w_buf_size: 65536 - pkg_rq_size: 1024 - pkg_wq_size: 512 - tcp_read_timeout: "1s" - tcp_write_timeout: "5s" - wait_timeout: "1s" - max_msg_len: 1024000 - session_name: "server" diff --git a/direct/go-server/pkg/user.go b/direct/go-server/pkg/user.go deleted file mode 100644 index 75d0916..0000000 --- a/direct/go-server/pkg/user.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 pkg - -import ( - "context" - "time" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/config" - - hessian "github.com/apache/dubbo-go-hessian2" - - "github.com/dubbogo/gost/log" -) - -func init() { - config.SetProviderService(new(UserProvider)) - // ------for hessian2------ - hessian.RegisterPOJO(&User{}) -} - -type User struct { - ID string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct { -} - -func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) { - gxlog.CInfo("req:%#v", req) - rsp := User{"A001", "Alex Stocks", 18, time.Now()} - gxlog.CInfo("rsp:%#v", rsp) - return &rsp, nil -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (u User) JavaClassName() string { - return "org.apache.dubbo.User" -} diff --git a/direct/go-server/tests/integration/main_test.go b/direct/go-server/tests/integration/main_test.go deleted file mode 100644 index d028c55..0000000 --- a/direct/go-server/tests/integration/main_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// +build integration - -/* - * 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" - "os" - "testing" - "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/config" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" - _ "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" -) - -var userProvider = new(UserProvider) - -func TestMain(m *testing.M) { - config.SetConsumerService(userProvider) - hessian.RegisterPOJO(&User{}) - config.Load() - time.Sleep(3 * time.Second) - - os.Exit(m.Run()) -} - -type User struct { - ID string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (User) JavaClassName() string { - return "org.apache.dubbo.User" -} diff --git a/direct/go-server/tests/integration/userprovider_test.go b/direct/go-server/tests/integration/userprovider_test.go deleted file mode 100644 index 7183e64..0000000 --- a/direct/go-server/tests/integration/userprovider_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// +build integration - -/* - * 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" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestGetUser(t *testing.T) { - user := &User{} - err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) - assert.Nil(t, err) - assert.Equal(t, "A001", user.ID) - assert.Equal(t, "Alex Stocks", user.Name) - assert.Equal(t, int32(18), user.Age) - assert.NotNil(t, user.Time) -} diff --git a/go.mod b/go.mod index d9d33bc..19e3050 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/apache/dubbo-go-samples require ( - dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210826094458-8ef173e7a77b + dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210901104537-ddabb2e957aa github.com/alibaba/sentinel-golang v1.0.2 github.com/apache/dubbo-getty v1.4.5 github.com/apache/dubbo-go-hessian2 v1.9.2 @@ -28,8 +28,6 @@ require ( k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect ) -replace ( - github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.0 -) +replace github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.0 go 1.13 diff --git a/go.sum b/go.sum index a608633..df43e51 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,10 @@ dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210822082425-1bfface3303e h1:TnZXDmo dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210822082425-1bfface3303e/go.mod h1:quHg7AMGZichyo/h2msHsjregY4oL0lEJlljPbpwgs0= dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210826094458-8ef173e7a77b h1:swahNLXhkWgQtnkgafdaHPaEWcC51PvEalPY+ovZ6JQ= dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210826094458-8ef173e7a77b/go.mod h1:truc+fGVX3f/luIG6lAc8D49JXETiRtWDF5CVkG7ZMY= +dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210901104537-ddabb2e957aa h1:xpWQD2HMHsDT9GqLQ6UzNz3rmI/eWa67/wbSbU3K3/k= +dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210901104537-ddabb2e957aa/go.mod h1:truc+fGVX3f/luIG6lAc8D49JXETiRtWDF5CVkG7ZMY= +dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210902110215-82e825c9c36a h1:MQe72C0+cCE3ra6Bk/MtmK3PTrNhNWvnopcOsTW7dP4= +dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210902110215-82e825c9c36a/go.mod h1:truc+fGVX3f/luIG6lAc8D49JXETiRtWDF5CVkG7ZMY= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= @@ -595,6 +599,7 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -703,6 +708,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -1091,6 +1097,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= diff --git a/helloworld/go-client/cmd/client.go b/helloworld/go-client/cmd/client.go index 2c0c7ad..59596d6 100644 --- a/helloworld/go-client/cmd/client.go +++ b/helloworld/go-client/cmd/client.go @@ -34,13 +34,12 @@ import ( var grpcGreeterImpl = new(api.GreeterClientImpl) -func init() { - config.SetConsumerService(grpcGreeterImpl) -} - // export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/helloworld/go-client/conf/dubbogo.yml func main() { - config.Load() + config.SetConsumerService(grpcGreeterImpl) + if err := config.Load(); err != nil { + panic(err) + } time.Sleep(3 * time.Second) logger.Info("start to test dubbo") diff --git a/helloworld/go-server/conf/dubbogo.yml b/helloworld/go-server/conf/dubbogo.yml index 5e9cfb4..aca4f05 100644 --- a/helloworld/go-server/conf/dubbogo.yml +++ b/helloworld/go-server/conf/dubbogo.yml @@ -1,17 +1,17 @@ dubbo: registries: "demoZK": - protocol: "zookeeper" - timeout: "3s" - address: "127.0.0.1:2181" + protocol: zookeeper + timeout: 3s + address: 127.0.0.1:2181 protocols: "triple": - name: "tri" + 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 \ No newline at end of file + protocol: triple + interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible with grpc or dubbo-java \ No newline at end of file diff --git a/integrate_test/helloworld/tests/integration/userprovider_test.go b/integrate_test/config-api/rpc/triple/tests/integration/configapi_rpc_triple_test.go similarity index 85% copy from integrate_test/helloworld/tests/integration/userprovider_test.go copy to integrate_test/config-api/rpc/triple/tests/integration/configapi_rpc_triple_test.go index 1daa809..bae2374 100644 --- a/integrate_test/helloworld/tests/integration/userprovider_test.go +++ b/integrate_test/config-api/rpc/triple/tests/integration/configapi_rpc_triple_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,25 +21,20 @@ import ( "context" "testing" ) - import ( "github.com/stretchr/testify/assert" ) import ( - dubbo3pb "github.com/apache/dubbo-go-samples/api" + "github.com/apache/dubbo-go-samples/api" ) func TestSayHello(t *testing.T) { - req := &dubbo3pb.HelloRequest{ + req := &api.HelloRequest{ Name: "laurence", } - reply := &dubbo3pb.User{} - ctx := context.Background() - ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX") - reply, err := greeterProvider.SayHello(ctx, req) assert.Nil(t, err) diff --git a/integrate_test/config-api/rpc/triple/tests/integration/main_test.go b/integrate_test/config-api/rpc/triple/tests/integration/main_test.go index d8a0568..5706621 100644 --- a/integrate_test/config-api/rpc/triple/tests/integration/main_test.go +++ b/integrate_test/config-api/rpc/triple/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -22,31 +20,43 @@ package integration import ( "os" "testing" - "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/config" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" - _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" - _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" - _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" + _ "dubbo.apache.org/dubbo-go/v3/imports" ) import ( - dubbo3pb "github.com/apache/dubbo-go-samples/api" + "github.com/apache/dubbo-go-samples/api" ) -var greeterProvider = new(dubbo3pb.GreeterClientImpl) +var greeterProvider = new(api.GreeterClientImpl) func TestMain(m *testing.M) { config.SetConsumerService(greeterProvider) - config.Load() - time.Sleep(3 * time.Second) + + referenceConfig := config.NewReferenceConfig( + config.WithReferenceInterface("com.apache.dubbo.sample.basic.IGreeter"), + config.WithReferenceProtocolName("tri"), + config.WithReferenceRegistry("zkRegistryKey"), + ) + + consumerConfig := config.NewConsumerConfig( + config.WithConsumerReferenceConfig("greeterImpl", referenceConfig), + ) + + registryConfig := config.NewRegistryConfigWithProtocolDefaultPort("zookeeper") + + rootConfig := config.NewRootConfig( + config.WithRootRegistryConfig("zkRegistryKey", registryConfig), + config.WithRootConsumerConfig(consumerConfig), + ) + + if err := rootConfig.Init(); err != nil { + panic(err) + } os.Exit(m.Run()) + } diff --git a/integrate_test/configcenter/apollo/tests/integration/greeterProvider_test.go b/integrate_test/configcenter/apollo/tests/integration/greeterProvider_test.go index 992c55d..2d177f5 100644 --- a/integrate_test/configcenter/apollo/tests/integration/greeterProvider_test.go +++ b/integrate_test/configcenter/apollo/tests/integration/greeterProvider_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -37,12 +35,7 @@ func TestSayHello(t *testing.T) { Name: "laurence", } - reply := &dubbo3pb.User{} - - ctx := context.Background() - ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX") - - err := greeterProvider.SayHello(ctx, req, reply) + reply, err := greeterProvider.SayHello(context.Background(), req) assert.Nil(t, err) assert.Equal(t, "Hello laurence", reply.Name) diff --git a/integrate_test/configcenter/apollo/tests/integration/main_test.go b/integrate_test/configcenter/apollo/tests/integration/main_test.go index d8a0568..07978d7 100644 --- a/integrate_test/configcenter/apollo/tests/integration/main_test.go +++ b/integrate_test/configcenter/apollo/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/integrate_test/configcenter/nacos/tests/integration/main_test.go b/integrate_test/configcenter/nacos/tests/integration/main_test.go index c2862bd..9eb9c0c 100644 --- a/integrate_test/configcenter/nacos/tests/integration/main_test.go +++ b/integrate_test/configcenter/nacos/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -60,11 +58,7 @@ type User struct { } type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" + GetUser func(ctx context.Context, req *User) (*User, error) } func (User) JavaClassName() string { diff --git a/integrate_test/configcenter/nacos/tests/integration/userprovider_test.go b/integrate_test/configcenter/nacos/tests/integration/userprovider_test.go index 7183e64..fbb9061 100644 --- a/integrate_test/configcenter/nacos/tests/integration/userprovider_test.go +++ b/integrate_test/configcenter/nacos/tests/integration/userprovider_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -29,8 +27,7 @@ import ( ) func TestGetUser(t *testing.T) { - user := &User{} - err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) + user, err := userProvider.GetUser(context.TODO(), &User{ID: "A001"}) assert.Nil(t, err) assert.Equal(t, "A001", user.ID) assert.Equal(t, "Alex Stocks", user.Name) diff --git a/rpc/dubbo3/codec-extension/go-server/docker/docker-compose.yml b/integrate_test/direct/docker/docker-compose.yml similarity index 100% rename from rpc/dubbo3/codec-extension/go-server/docker/docker-compose.yml rename to integrate_test/direct/docker/docker-compose.yml diff --git a/rpc/dubbo3/codec-extension/go-server/docker/docker-health-check.sh b/integrate_test/direct/docker/docker-health-check.sh similarity index 100% rename from rpc/dubbo3/codec-extension/go-server/docker/docker-health-check.sh rename to integrate_test/direct/docker/docker-health-check.sh diff --git a/integrate_test/config-api/rpc/triple/tests/integration/main_test.go b/integrate_test/direct/tests/integration/main_test.go similarity index 98% copy from integrate_test/config-api/rpc/triple/tests/integration/main_test.go copy to integrate_test/direct/tests/integration/main_test.go index d8a0568..07978d7 100644 --- a/integrate_test/config-api/rpc/triple/tests/integration/main_test.go +++ b/integrate_test/direct/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/integrate_test/helloworld/tests/integration/userprovider_test.go b/integrate_test/direct/tests/integration/userprovider_test.go similarity index 93% copy from integrate_test/helloworld/tests/integration/userprovider_test.go copy to integrate_test/direct/tests/integration/userprovider_test.go index 1daa809..971a8a8 100644 --- a/integrate_test/helloworld/tests/integration/userprovider_test.go +++ b/integrate_test/direct/tests/integration/userprovider_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -40,7 +38,6 @@ func TestSayHello(t *testing.T) { reply := &dubbo3pb.User{} ctx := context.Background() - ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX") reply, err := greeterProvider.SayHello(ctx, req) diff --git a/integrate_test/helloworld/docker/docker-compose.yml~merged b/integrate_test/helloworld/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/integrate_test/helloworld/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/integrate_test/config-api/rpc/triple/tests/integration/userprovider_test.go b/integrate_test/helloworld/tests/integration/helloworld_test.go similarity index 90% rename from integrate_test/config-api/rpc/triple/tests/integration/userprovider_test.go rename to integrate_test/helloworld/tests/integration/helloworld_test.go index 992c55d..971a8a8 100644 --- a/integrate_test/config-api/rpc/triple/tests/integration/userprovider_test.go +++ b/integrate_test/helloworld/tests/integration/helloworld_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -40,9 +38,8 @@ func TestSayHello(t *testing.T) { reply := &dubbo3pb.User{} ctx := context.Background() - ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX") - err := greeterProvider.SayHello(ctx, req, reply) + reply, err := greeterProvider.SayHello(ctx, req) assert.Nil(t, err) assert.Equal(t, "Hello laurence", reply.Name) diff --git a/integrate_test/helloworld/tests/integration/main_test.go b/integrate_test/helloworld/tests/integration/main_test.go index d8a0568..07978d7 100644 --- a/integrate_test/helloworld/tests/integration/main_test.go +++ b/integrate_test/helloworld/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/integrate_test/registry/zookeeper/docker/docker-compose.yml~merged b/integrate_test/registry/zookeeper/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/integrate_test/registry/zookeeper/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/integrate_test/registry/zookeeper/docker/docker-health-check.sh~merged b/integrate_test/registry/zookeeper/docker/docker-health-check.sh~merged deleted file mode 100644 index 2cc32c2..0000000 --- a/integrate_test/registry/zookeeper/docker/docker-health-check.sh~merged +++ /dev/null @@ -1,10 +0,0 @@ -curl 127.0.0.1:2181 -res=$? -passCode=52 -while [ "$res" != "$passCode" ];do - sleep 5 - curl 127.0.0.1:2181 - res=$? -done - -sleep 5 diff --git a/integrate_test/helloworld/tests/integration/userprovider_test.go b/integrate_test/registry/zookeeper/tests/integration/helloworld_test.go similarity index 93% rename from integrate_test/helloworld/tests/integration/userprovider_test.go rename to integrate_test/registry/zookeeper/tests/integration/helloworld_test.go index 1daa809..971a8a8 100644 --- a/integrate_test/helloworld/tests/integration/userprovider_test.go +++ b/integrate_test/registry/zookeeper/tests/integration/helloworld_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -40,7 +38,6 @@ func TestSayHello(t *testing.T) { reply := &dubbo3pb.User{} ctx := context.Background() - ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX") reply, err := greeterProvider.SayHello(ctx, req) diff --git a/integrate_test/registry/zookeeper/tests/integration/main_test.go b/integrate_test/registry/zookeeper/tests/integration/main_test.go index d028c55..07978d7 100644 --- a/integrate_test/registry/zookeeper/tests/integration/main_test.go +++ b/integrate_test/registry/zookeeper/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,7 +18,6 @@ package integration import ( - "context" "os" "testing" "time" @@ -36,36 +33,18 @@ import ( _ "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" +import ( + dubbo3pb "github.com/apache/dubbo-go-samples/api" ) -var userProvider = new(UserProvider) +var greeterProvider = new(dubbo3pb.GreeterClientImpl) func TestMain(m *testing.M) { - config.SetConsumerService(userProvider) - hessian.RegisterPOJO(&User{}) + config.SetConsumerService(greeterProvider) config.Load() time.Sleep(3 * time.Second) os.Exit(m.Run()) } - -type User struct { - ID string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (User) JavaClassName() string { - return "org.apache.dubbo.User" -} diff --git a/integrate_test/registry/zookeeper/tests/integration/userprovider_test.go b/integrate_test/registry/zookeeper/tests/integration/userprovider_test.go deleted file mode 100644 index 7183e64..0000000 --- a/integrate_test/registry/zookeeper/tests/integration/userprovider_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// +build integration - -/* - * 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" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestGetUser(t *testing.T) { - user := &User{} - err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) - assert.Nil(t, err) - assert.Equal(t, "A001", user.ID) - assert.Equal(t, "Alex Stocks", user.Name) - assert.Equal(t, int32(18), user.Age) - assert.NotNil(t, user.Time) -} diff --git a/integrate_test/rpc/hessian2/docker/docker-compose.yml b/integrate_test/rpc/dubbo3/codec-extension/docker/docker-compose.yml similarity index 100% rename from integrate_test/rpc/hessian2/docker/docker-compose.yml rename to integrate_test/rpc/dubbo3/codec-extension/docker/docker-compose.yml diff --git a/integrate_test/rpc/hessian2/docker/docker-health-check.sh b/integrate_test/rpc/dubbo3/codec-extension/docker/docker-health-check.sh similarity index 100% rename from integrate_test/rpc/hessian2/docker/docker-health-check.sh rename to integrate_test/rpc/dubbo3/codec-extension/docker/docker-health-check.sh diff --git a/rpc/dubbo3/codec-extension/go-server/tests/integration/codec.go b/integrate_test/rpc/dubbo3/codec-extension/tests/integration/codec.go similarity index 100% rename from rpc/dubbo3/codec-extension/go-server/tests/integration/codec.go rename to integrate_test/rpc/dubbo3/codec-extension/tests/integration/codec.go diff --git a/rpc/dubbo3/codec-extension/go-server/tests/integration/main_test.go b/integrate_test/rpc/dubbo3/codec-extension/tests/integration/main_test.go similarity index 95% rename from rpc/dubbo3/codec-extension/go-server/tests/integration/main_test.go rename to integrate_test/rpc/dubbo3/codec-extension/tests/integration/main_test.go index d7edc46..a4d4bc8 100644 --- a/rpc/dubbo3/codec-extension/go-server/tests/integration/main_test.go +++ b/integrate_test/rpc/dubbo3/codec-extension/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -54,7 +52,7 @@ type User struct { } type UserProvider struct { - GetUser func(ctx context.Context, req *User, rsp *User) error + GetUser func(ctx context.Context, req *User, req2 *User, name string) (*User, error) } func (u *UserProvider) Reference() string { diff --git a/integrate_test/rpc/hessian2/tests/integration/userprovider_test.go b/integrate_test/rpc/dubbo3/codec-extension/tests/integration/userprovider_test.go similarity index 86% rename from integrate_test/rpc/hessian2/tests/integration/userprovider_test.go rename to integrate_test/rpc/dubbo3/codec-extension/tests/integration/userprovider_test.go index 639e911..6ebc619 100644 --- a/integrate_test/rpc/hessian2/tests/integration/userprovider_test.go +++ b/integrate_test/rpc/dubbo3/codec-extension/tests/integration/userprovider_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -29,10 +27,9 @@ import ( ) func TestGetUser(t *testing.T) { - user := &User{} - err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"}, user) + user, err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"}, &User{Name: "laurence2"}, "myname") assert.Nil(t, err) assert.Equal(t, "12345", user.ID) - assert.Equal(t, "laurence", user.Name) + assert.Equal(t, "laurencelaurence2", user.Name) assert.Equal(t, int32(18), user.Age) } diff --git a/integrate_test/rpc/hessian2/conf/client.yml b/integrate_test/rpc/dubbo3/hessian2/conf/client.yml similarity index 100% rename from integrate_test/rpc/hessian2/conf/client.yml rename to integrate_test/rpc/dubbo3/hessian2/conf/client.yml diff --git a/rpc/dubbo3/codec-extension/go-server/conf/log.yml b/integrate_test/rpc/dubbo3/hessian2/conf/log.yml similarity index 100% rename from rpc/dubbo3/codec-extension/go-server/conf/log.yml rename to integrate_test/rpc/dubbo3/hessian2/conf/log.yml diff --git a/integrate_test/rpc/hessian2/conf/server.yml b/integrate_test/rpc/dubbo3/hessian2/conf/server.yml similarity index 100% rename from integrate_test/rpc/hessian2/conf/server.yml rename to integrate_test/rpc/dubbo3/hessian2/conf/server.yml diff --git a/direct/go-server/docker/docker-compose.yml b/integrate_test/rpc/dubbo3/hessian2/docker/docker-compose.yml similarity index 100% rename from direct/go-server/docker/docker-compose.yml rename to integrate_test/rpc/dubbo3/hessian2/docker/docker-compose.yml diff --git a/direct/go-server/docker/docker-health-check.sh b/integrate_test/rpc/dubbo3/hessian2/docker/docker-health-check.sh similarity index 100% rename from direct/go-server/docker/docker-health-check.sh rename to integrate_test/rpc/dubbo3/hessian2/docker/docker-health-check.sh diff --git a/integrate_test/rpc/hessian2/tests/integration/main_test.go b/integrate_test/rpc/dubbo3/hessian2/tests/integration/main_test.go similarity index 88% rename from integrate_test/rpc/hessian2/tests/integration/main_test.go rename to integrate_test/rpc/dubbo3/hessian2/tests/integration/main_test.go index 2b781ca..3d662e2 100644 --- a/integrate_test/rpc/hessian2/tests/integration/main_test.go +++ b/integrate_test/rpc/dubbo3/hessian2/tests/integration/main_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -47,7 +45,6 @@ func TestMain(m *testing.M) { hessian.RegisterPOJO(&User{}) config.Load() time.Sleep(3 * time.Second) - os.Exit(m.Run()) } @@ -58,13 +55,9 @@ type User struct { } type UserProvider struct { - GetUser func(ctx context.Context, usr *User, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" + GetUser func(ctx context.Context, usr *User) (*User, error) } -func (u User) JavaClassName() string { - return "org.apache.dubbo.User" +func (u *User) JavaClassName() string { + return "com.apache.dubbo.sample.basic.User" } diff --git a/rpc/dubbo3/codec-extension/go-server/tests/integration/userprovider_test.go b/integrate_test/rpc/dubbo3/hessian2/tests/integration/userprovider_test.go similarity index 90% rename from rpc/dubbo3/codec-extension/go-server/tests/integration/userprovider_test.go rename to integrate_test/rpc/dubbo3/hessian2/tests/integration/userprovider_test.go index 7a08d19..ee3607f 100644 --- a/rpc/dubbo3/codec-extension/go-server/tests/integration/userprovider_test.go +++ b/integrate_test/rpc/dubbo3/hessian2/tests/integration/userprovider_test.go @@ -1,5 +1,3 @@ -// +build integration - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -29,8 +27,7 @@ import ( ) func TestGetUser(t *testing.T) { - user := &User{} - err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"}, user) + user, err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"}) assert.Nil(t, err) assert.Equal(t, "12345", user.ID) assert.Equal(t, "Hello laurence", user.Name) diff --git a/integrate_test/rpc/hessian2/conf/log.yml b/integrate_test/rpc/hessian2/conf/log.yml deleted file mode 100644 index 8c3f700..0000000 --- a/integrate_test/rpc/hessian2/conf/log.yml +++ /dev/null @@ -1,27 +0,0 @@ -level: "info" -development: true -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capital" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/integrate_test/rpc/hessian2/docker/docker-compose.yml~merged b/integrate_test/rpc/hessian2/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/integrate_test/rpc/hessian2/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/rpc/dubbo/go-client/cmd/client.go b/rpc/dubbo/go-client/cmd/client.go index 5cdcdf8..dcd1939 100644 --- a/rpc/dubbo/go-client/cmd/client.go +++ b/rpc/dubbo/go-client/cmd/client.go @@ -38,7 +38,7 @@ import ( ) import ( - "github.com/apache/dubbo-go-samples/general/dubbo/go-client/pkg" + "github.com/apache/dubbo-go-samples/rpc/dubbo/go-client/pkg" ) var ( diff --git a/rpc/dubbo/go-server/cmd/server.go b/rpc/dubbo/go-server/cmd/server.go index 32a7a0e..fc74d81 100644 --- a/rpc/dubbo/go-server/cmd/server.go +++ b/rpc/dubbo/go-server/cmd/server.go @@ -41,7 +41,7 @@ import ( ) import ( - "github.com/apache/dubbo-go-samples/general/dubbo/go-server/pkg" + "github.com/apache/dubbo-go-samples/rpc/dubbo/go-server/pkg" ) var ( diff --git a/rpc/dubbo/go-server/docker/docker-compose.yml~merged b/rpc/dubbo/go-server/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/rpc/dubbo/go-server/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/rpc/dubbo/go-server/docker/docker-health-check.sh~merged b/rpc/dubbo/go-server/docker/docker-health-check.sh~merged deleted file mode 100644 index 2cc32c2..0000000 --- a/rpc/dubbo/go-server/docker/docker-health-check.sh~merged +++ /dev/null @@ -1,10 +0,0 @@ -curl 127.0.0.1:2181 -res=$? -passCode=52 -while [ "$res" != "$passCode" ];do - sleep 5 - curl 127.0.0.1:2181 - res=$? -done - -sleep 5 diff --git a/rpc/dubbo/go-server/tests/integration/userprovider_test.go b/rpc/dubbo/go-server/tests/integration/userprovider_test.go index 988e1cd..3fe5d8d 100644 --- a/rpc/dubbo/go-server/tests/integration/userprovider_test.go +++ b/rpc/dubbo/go-server/tests/integration/userprovider_test.go @@ -31,7 +31,7 @@ import ( ) import ( - "github.com/apache/dubbo-go-samples/general/dubbo/go-server/pkg" + "github.com/apache/dubbo-go-samples/rpc/dubbo/go-server/pkg" ) func TestGetUserA000(t *testing.T) { diff --git a/rpc/dubbo3/codec-extension/go-server/codec/codec.go b/rpc/dubbo3/codec-extension/codec/codec.go similarity index 100% rename from rpc/dubbo3/codec-extension/go-server/codec/codec.go rename to rpc/dubbo3/codec-extension/codec/codec.go diff --git a/rpc/dubbo3/codec-extension/go-client/cmd/client.go b/rpc/dubbo3/codec-extension/go-client/cmd/client.go index 9090ea5..087b7a5 100644 --- a/rpc/dubbo3/codec-extension/go-client/cmd/client.go +++ b/rpc/dubbo3/codec-extension/go-client/cmd/client.go @@ -19,47 +19,41 @@ 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/dubbo3" - _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc" - _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" - _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" - - "github.com/dubbogo/gost/log" + _ "dubbo.apache.org/dubbo-go/v3/imports" ) import ( - _ "github.com/apache/dubbo-go-samples/general/dubbo3/codec-extension/go-client/codec" - "github.com/apache/dubbo-go-samples/general/dubbo3/codec-extension/go-client/pkg" + _ "github.com/apache/dubbo-go-samples/rpc/dubbo3/codec-extension/codec" ) -var userProvider = new(pkg.UserProvider) +type User struct { + ID string + Name string + Age int32 +} -func init() { - config.SetConsumerService(userProvider) +type UserProvider struct { + GetUser func(context.Context, *User, *User, string) (*User, error) } -// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run +var userProvider = new(UserProvider) + +// export DUBBO_GO_CONFIG_PATH=PATH_TO_SAMPLES/rpc/dubbo3/codec-extension/go-client/conf/dubbogo.yml func main() { - config.Load() + config.SetConsumerService(userProvider) + 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(), &pkg.User{Name: "laurence"}, user) + user, err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"}, &User{Name: "laurence2"}, "testName") if err != nil { - gxlog.CError("error: %v\n", err) - os.Exit(1) - return + panic(err) } - gxlog.CInfo("response result: %v\n", user) + logger.Infof("response result: %v\n", user) } diff --git a/rpc/dubbo3/codec-extension/go-client/codec/codec.go b/rpc/dubbo3/codec-extension/go-client/codec/codec.go deleted file mode 100644 index 68805e9..0000000 --- a/rpc/dubbo3/codec-extension/go-client/codec/codec.go +++ /dev/null @@ -1,28 +0,0 @@ -package codec - -import ( - "encoding/json" -) - -import ( - triCommon "github.com/dubbogo/triple/pkg/common" -) - -func init() { - triCommon.SetTripleCodec("json", NewJSONCodec) -} - -func NewJSONCodec() triCommon.Codec { - return &JSONCodec{} -} - -type JSONCodec struct { -} - -func (j *JSONCodec) Marshal(v interface{}) ([]byte, error) { - return json.Marshal(v) -} - -func (j *JSONCodec) Unmarshal(data []byte, v interface{}) error { - return json.Unmarshal(data, v) -} diff --git a/rpc/dubbo3/codec-extension/go-client/conf/client.yml b/rpc/dubbo3/codec-extension/go-client/conf/client.yml deleted file mode 100644 index d4c14a2..0000000 --- a/rpc/dubbo3/codec-extension/go-client/conf/client.yml +++ /dev/null @@ -1,33 +0,0 @@ -# dubbo client yaml configure file - -check: true -# client -request_timeout: "3s" -# connect timeout -connect_timeout: "3s" - -# application config -application: - organization: "dubbo.io" - name: "UserProvider" - module: "dubbo-go3.0 client" - version: "0.0.1" - environment: "dev" - -# registry config -registries: - "demoZk": - protocol: "zookeeper" - timeout: "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - -# reference config -references: - "UserProvider": - registry: "demoZk" - protocol: "tri" - serialization: "json" -# url: "dubbo://127.0.0.1:20000" # target server ip:port - interface: "com.apache.dubbo.sample.basic.IGreeter" diff --git a/rpc/dubbo3/codec-extension/go-client/conf/dubbogo.yml b/rpc/dubbo3/codec-extension/go-client/conf/dubbogo.yml new file mode 100644 index 0000000..5aaef86 --- /dev/null +++ b/rpc/dubbo3/codec-extension/go-client/conf/dubbogo.yml @@ -0,0 +1,12 @@ +dubbo: + registries: + registryKey: + protocol: zookeeper + address: 127.0.0.1:2181 + consumer: + registry: + - registryKey + references: + UserProvider: + protocol: tri + interface: com.apache.dubbogo.samples.rpc.extension.UserProvider # must be compatible with grpc or dubbo-java server \ No newline at end of file diff --git a/rpc/dubbo3/codec-extension/go-client/conf/log.yml b/rpc/dubbo3/codec-extension/go-client/conf/log.yml deleted file mode 100644 index 8c3f700..0000000 --- a/rpc/dubbo3/codec-extension/go-client/conf/log.yml +++ /dev/null @@ -1,27 +0,0 @@ -level: "info" -development: true -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capital" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/rpc/dubbo3/codec-extension/go-client/pkg/hello.go b/rpc/dubbo3/codec-extension/go-client/pkg/hello.go deleted file mode 100644 index da5c377..0000000 --- a/rpc/dubbo3/codec-extension/go-client/pkg/hello.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 pkg - -import ( - "context" -) - -type User struct { - ID string - Name string - Age int32 -} - -type UserProvider struct { - GetUser func(ctx context.Context, req *User, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} diff --git a/rpc/dubbo3/codec-extension/go-server/cmd/server.go b/rpc/dubbo3/codec-extension/go-server/cmd/server.go index 27d439d..0555c45 100644 --- a/rpc/dubbo3/codec-extension/go-server/cmd/server.go +++ b/rpc/dubbo3/codec-extension/go-server/cmd/server.go @@ -1,84 +1,59 @@ /* -* 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. + * 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 ( - "fmt" - "os" - "os/signal" - "syscall" - "time" + "context" ) 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/logger" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" - _ "dubbo.apache.org/dubbo-go/v3/registry/nacos" - _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" - _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" - - _ "github.com/dubbogo/triple/pkg/triple" + _ "dubbo.apache.org/dubbo-go/v3/imports" ) import ( - _ "github.com/apache/dubbo-go-samples/general/dubbo3/codec-extension/go-client/codec" - "github.com/apache/dubbo-go-samples/general/dubbo3/codec-extension/go-server/pkg" -) - -var ( - survivalTimeout = int(3 * time.Second) + _ "github.com/apache/dubbo-go-samples/rpc/dubbo3/codec-extension/codec" ) -func init() { - config.SetProviderService(new(pkg.UserProvider)) +type User struct { + ID string + Name string + Age int32 } -// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to "conf/server.yml" before run -func main() { - config.Load() - initSignal() +type UserProvider struct { } -func initSignal() { - signals := make(chan os.Signal, 1) - // It is not possible to block SIGKILL or syscall.SIGSTOP - signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) - for { - sig := <-signals - logger.Infof("get signal %s", sig.String()) - switch sig { - case syscall.SIGHUP: - // reload() - default: - time.Sleep(time.Second * 5) - time.AfterFunc(time.Duration(survivalTimeout), func() { - logger.Warnf("app exit now by force...") - os.Exit(1) - }) +func (u *UserProvider) GetUser(ctx context.Context, req *User, req2 *User, name string) (*User, error) { + logger.Infof("req:%#v", req) + logger.Infof("req2:%#v", req2) + logger.Infof("name%#v", name) + rsp := User{"12345", req.Name + req2.Name, 18} + logger.Infof("rsp:%#v", rsp) + return &rsp, nil +} - // The program exits normally or timeout forcibly exits. - fmt.Println("provider app exit now...") - return - } +// export DUBBO_GO_CONFIG_PATH=PATH_TO_SAMPLES/rpc/dubbo3/codec-extension/go-server/conf/dubbogo.yml +func main() { + config.SetProviderService(&UserProvider{}) + if err := config.Load(); err != nil { + panic(err) } + select {} } diff --git a/rpc/dubbo3/codec-extension/go-server/conf/client.yml b/rpc/dubbo3/codec-extension/go-server/conf/client.yml deleted file mode 100644 index 137d8b2..0000000 --- a/rpc/dubbo3/codec-extension/go-server/conf/client.yml +++ /dev/null @@ -1,32 +0,0 @@ -# dubbo client yaml configure file - -check: true -# client -request_timeout: "3s" -# connect timeout -connect_timeout: "3s" - -# application config -application: - organization: "dubbo.io" - name: "UserProvider" - module: "dubbo-go3.0 client" - version: "0.0.1" - environment: "dev" - -# registry config -registries: - "demoZk": - protocol: "zookeeper" - timeout: "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - -# reference config -references: - "UserProvider": - registry: "demoZk" - protocol: "tri" - serialization: "json" - interface: "com.apache.dubbo.sample.basic.IGreeter" diff --git a/rpc/dubbo3/codec-extension/go-server/conf/dubbogo.yml b/rpc/dubbo3/codec-extension/go-server/conf/dubbogo.yml new file mode 100644 index 0000000..77d7c97 --- /dev/null +++ b/rpc/dubbo3/codec-extension/go-server/conf/dubbogo.yml @@ -0,0 +1,17 @@ +dubbo: + registries: + registryKey: + protocol: zookeeper + address: 127.0.0.1:2181 + protocols: + tripleKey: + name: tri + port: 20000 + provider: + registry: + - registryKey + services: + UserProvider: + protocol: tripleKey + serialization: json + interface: com.apache.dubbogo.samples.rpc.extension.UserProvider # must be compatible with grpc or dubbo-java \ No newline at end of file diff --git a/rpc/dubbo3/codec-extension/go-server/conf/server.yml b/rpc/dubbo3/codec-extension/go-server/conf/server.yml deleted file mode 100644 index 4e8d051..0000000 --- a/rpc/dubbo3/codec-extension/go-server/conf/server.yml +++ /dev/null @@ -1,30 +0,0 @@ -# dubbo server yaml configure file - -# application config -application: - organization: "dubbo.io" - name: "UserProvider" - module: "dubbo-go3.0 greeter server" - version: "0.0.1" - environment: "dev" - -# registry config -registries: - "demoZK": - protocol: "zookeeper" - timeout: "3s" - address: "127.0.0.1:2181" - -# service config -services: - "UserProvider": - registry: "demoZK" - protocol: "tri" # tri is dubbo-go3.0 protocol - serialization: "json" # json is user defined serialization type - interface: "com.apache.dubbo.sample.basic.IGreeter" - -# protocol config -protocols: - "tri": - name: "tri" - port: 20001 diff --git a/rpc/dubbo3/codec-extension/go-server/docker/docker-compose.yml~merged b/rpc/dubbo3/codec-extension/go-server/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/rpc/dubbo3/codec-extension/go-server/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/rpc/dubbo3/codec-extension/go-server/pkg/greeter.go b/rpc/dubbo3/codec-extension/go-server/pkg/greeter.go deleted file mode 100644 index 52d08fd..0000000 --- a/rpc/dubbo3/codec-extension/go-server/pkg/greeter.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 pkg - -import ( - "context" -) - -import ( - "github.com/dubbogo/gost/log" -) - -type User struct { - ID string - Name string - Age int32 -} - -type UserProvider struct { -} - -func (u *UserProvider) GetUser(ctx context.Context, user *User) (*User, error) { - gxlog.CInfo("req:%#v", user) - rsp := User{"12345", "Hello " + user.Name, 18} - gxlog.CInfo("rsp:%#v", rsp) - return &rsp, nil -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} diff --git a/rpc/dubbo3/hessian2/go-server/cmd/simple_service.go b/rpc/dubbo3/hessian2/go-server/cmd/simple_service.go index 93dc772..3513b11 100644 --- a/rpc/dubbo3/hessian2/go-server/cmd/simple_service.go +++ b/rpc/dubbo3/hessian2/go-server/cmd/simple_service.go @@ -23,7 +23,7 @@ type UserProvider struct { func (u *UserProvider) GetUser(ctx context.Context, usr *User) (*User, error) { gxlog.CInfo("req:%#v", usr) - rsp := User{"12345", "" + usr.Name, 18} + rsp := User{"12345", "Hello " + usr.Name, 18} gxlog.CInfo("rsp:%#v", rsp) return &rsp, nil } diff --git a/rpc/dubbo3/msgpack/go-server/cmd/server.go b/rpc/dubbo3/msgpack/go-server/cmd/server.go index 9c956c0..f40729f 100644 --- a/rpc/dubbo3/msgpack/go-server/cmd/server.go +++ b/rpc/dubbo3/msgpack/go-server/cmd/server.go @@ -43,9 +43,9 @@ type UserProvider struct { func (u UserProvider) GetUser(ctx context.Context, user *api.User) (*api.User, error) { gxlog.CInfo("req:%#v", user) rsp := api.User{ - Name: "12345", - Id: "Hello " + user.Name, - Age: 18, + Name: "12345", + Id: "Hello " + user.Name, + Age: 18, } gxlog.CInfo("rsp:%#v", rsp) return &rsp, nil diff --git a/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/server.go b/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/server.go index c0e8c9d..d54bf26 100644 --- a/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/server.go +++ b/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/server.go @@ -41,7 +41,7 @@ import ( ) import ( - "github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/pkg" + "github.com/apache/dubbo-go-samples/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/pkg" ) var ( diff --git a/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/docker/docker-compose.yml~merged b/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/rpc/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/rpc/dubbo3/pb/dubbogo-grpc/server/grpcgo-server/main.go b/rpc/dubbo3/pb/dubbogo-grpc/server/grpcgo-server/main.go index 4041fb7..df828eb 100644 --- a/rpc/dubbo3/pb/dubbogo-grpc/server/grpcgo-server/main.go +++ b/rpc/dubbo3/pb/dubbogo-grpc/server/grpcgo-server/main.go @@ -28,7 +28,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/reflection" - "google.golang.org/grpc/reflection" ) import ( diff --git a/rpc/dubbo3/pb/dubbogo-java/go-server/docker/docker-compose.yml~merged b/rpc/dubbo3/pb/dubbogo-java/go-server/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/rpc/dubbo3/pb/dubbogo-java/go-server/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/rpc/grpc/go-client/cmd/client.go b/rpc/grpc/go-client/cmd/client.go index 940421e..c2e7fca 100644 --- a/rpc/grpc/go-client/cmd/client.go +++ b/rpc/grpc/go-client/cmd/client.go @@ -52,11 +52,10 @@ func main() { time.Sleep(3 * time.Second) gxlog.CInfo("\n\n\nstart to test dubbo") - reply := &protobuf.HelloReply{} req := &protobuf.HelloRequest{ Name: "xujianhai", } - err := grpcGreeterImpl.SayHello(context.TODO(), req, reply) + reply, err := grpcGreeterImpl.SayHello(context.TODO(), req) if err != nil { panic(err) } diff --git a/rpc/grpc/go-client/conf/log.yml~merged b/rpc/grpc/go-client/conf/log.yml~merged deleted file mode 100644 index 2b6e93a..0000000 --- a/rpc/grpc/go-client/conf/log.yml~merged +++ /dev/null @@ -1,27 +0,0 @@ -level: "debug" -development: true -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capital" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/rpc/grpc/go-server/conf/log.yml~merged b/rpc/grpc/go-server/conf/log.yml~merged deleted file mode 100644 index 970d988..0000000 --- a/rpc/grpc/go-server/conf/log.yml~merged +++ /dev/null @@ -1,27 +0,0 @@ -level: "error" -development: true -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capital" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/rpc/rest/go-client/docker/docker-compose.yml~merged b/rpc/rest/go-client/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/rpc/rest/go-client/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/rpc/rest/go-server/docker/docker-compose.yml~merged b/rpc/rest/go-server/docker/docker-compose.yml~merged deleted file mode 100644 index 8724179..0000000 --- a/rpc/rest/go-server/docker/docker-compose.yml~merged +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' - -services: - zookeeper: - image: zookeeper - ports: - - 2181:2181 - restart: on-failure - diff --git a/start_integrate_test.sh b/start_integrate_test.sh index b539384..0f6758d 100755 --- a/start_integrate_test.sh +++ b/start_integrate_test.sh @@ -88,7 +88,13 @@ ## the test of router logic would be fixed later #array+=("router/uniform-router/file/go-server") #array+=("router/uniform-router/file/go-server2") -array+=("helloworld") + +array=("helloworld") +array+=("direct") +array+=("config-api/rpc/triple") +array+=("registry/zookeeper") +array+=("rpc/dubbo3/codec-extension") +array+=("rpc/dubbo3/hessian2") for((i=0;i<${#array[*]};i++)) do diff --git a/tracing/grpc/go-server/app/helloworld.pb.go b/tracing/grpc/go-server/app/helloworld.pb.go index a6baf5c..e8bf208 100644 --- a/tracing/grpc/go-server/app/helloworld.pb.go +++ b/tracing/grpc/go-server/app/helloworld.pb.go @@ -18,8 +18,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" "google.golang.org/grpc/status" )
