This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/3.0 by this push:
new da8780a Ftr/3.0msgpack and triple codec extension samples (#138)
da8780a is described below
commit da8780ae1e31cf377a2aa642cd527b77bfb93a9c
Author: Laurence <[email protected]>
AuthorDate: Mon Jun 14 15:18:46 2021 +0800
Ftr/3.0msgpack and triple codec extension samples (#138)
* fix: updata go get dubbo-gen script
* fix
* fix: add etcd test
* fix: add msgpack sample
* fix
* fix
* fix: fix conflict
* fix: add test
* Fix: split import block
* fix: delete unused block
---
.run/triple-codec-extension-client.run.xml | 15 ++++
.run/triple-codec-extension-server.run.xml | 15 ++++
.run/triple-msgpack-client.run.xml | 15 ++++
.run/triple-msgpack-server.run.xml | 15 ++++
.../dubbo3/codec-extension/go-client/cmd/client.go | 64 +++++++++++++++++
.../codec-extension/go-client/codec/codec.go | 29 ++++++++
.../codec-extension/go-client/conf/client.yml | 33 +++++++++
.../dubbo3/codec-extension/go-client}/conf/log.yml | 3 +-
.../go-client/pkg/hello.go} | 25 +------
.../dubbo3/codec-extension/go-server/cmd/server.go | 83 ++++++++++++++++++++++
.../codec-extension/go-server/codec/codec.go | 25 +++++++
.../codec-extension/go-server/conf/client.yml | 32 +++++++++
.../dubbo3/codec-extension}/go-server/conf/log.yml | 3 +-
.../codec-extension/go-server/conf/server.yml | 30 ++++++++
.../go-server/docker/docker-compose.yml | 9 +++
.../go-server/pkg/greeter.go | 20 ++----
.../go-server/tests/integration/codec.go | 25 +++++++
.../go-server/tests/integration/main_test.go} | 45 ++++++------
.../tests/integration/userprovider_test.go} | 45 ++++--------
general/dubbo3/hessian2/go-server/pkg/greeter.go | 4 +-
general/dubbo3/msgpack/go-client/cmd/client.go | 63 ++++++++++++++++
general/dubbo3/msgpack/go-client/conf/client.yml | 33 +++++++++
.../dubbo3/msgpack/go-client}/conf/log.yml | 3 +-
.../greeter.go => msgpack/go-client/pkg/hello.go} | 25 +------
general/dubbo3/msgpack/go-server/cmd/server.go | 82 +++++++++++++++++++++
general/dubbo3/msgpack/go-server/conf/client.yml | 32 +++++++++
.../dubbo3/msgpack}/go-server/conf/log.yml | 3 +-
general/dubbo3/msgpack/go-server/conf/server.yml | 30 ++++++++
.../msgpack/go-server/docker/docker-compose.yml | 9 +++
.../{hessian2 => msgpack}/go-server/pkg/greeter.go | 22 ++----
.../go-server/tests/integration/main_test.go} | 45 ++++++------
.../tests/integration/userprovider_test.go} | 45 ++++--------
go.mod | 2 +-
go.sum | 3 +-
start_integrate_test.sh | 5 +-
tengine/go-server/conf/log.yml | 3 +-
36 files changed, 742 insertions(+), 198 deletions(-)
diff --git a/.run/triple-codec-extension-client.run.xml
b/.run/triple-codec-extension-client.run.xml
new file mode 100644
index 0000000..55591d0
--- /dev/null
+++ b/.run/triple-codec-extension-client.run.xml
@@ -0,0 +1,15 @@
+<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" />
+ <filePath value="$PROJECT_DIR$" />
+ <package
value="github.com/apache/dubbo-go-samples/general/dubbo3/codec-extension/go-client/cmd"
/>
+ <directory
value="github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd"
/>
+ <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
new file mode 100644
index 0000000..6b68920
--- /dev/null
+++ b/.run/triple-codec-extension-server.run.xml
@@ -0,0 +1,15 @@
+<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" />
+ <filePath value="$PROJECT_DIR$" />
+ <package
value="github.com/apache/dubbo-go-samples/general/dubbo3/codec-extension/go-server/cmd"
/>
+ <directory
value="github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd"
/>
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/triple-msgpack-client.run.xml
b/.run/triple-msgpack-client.run.xml
new file mode 100644
index 0000000..d265e2f
--- /dev/null
+++ b/.run/triple-msgpack-client.run.xml
@@ -0,0 +1,15 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="triple-msgpack-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/msgpack/go-client/conf/log.yml" />
+ <env name="CONF_CONSUMER_FILE_PATH"
value="$PROJECT_DIR$/general/dubbo3/msgpack/go-client/conf/client.yml" />
+ </envs>
+ <kind value="PACKAGE" />
+ <filePath value="$PROJECT_DIR$" />
+ <package
value="github.com/apache/dubbo-go-samples/general/dubbo3/msgpack/go-client/cmd"
/>
+ <directory
value="github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd"
/>
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/triple-msgpack-server.run.xml
b/.run/triple-msgpack-server.run.xml
new file mode 100644
index 0000000..8ef6570
--- /dev/null
+++ b/.run/triple-msgpack-server.run.xml
@@ -0,0 +1,15 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="triple-msgpack-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/msgpack/go-server/conf/log.yml" />
+ <env name="CONF_PROVIDER_FILE_PATH"
value="$PROJECT_DIR$/general/dubbo3/msgpack/go-server/conf/server.yml" />
+ </envs>
+ <kind value="PACKAGE" />
+ <filePath value="$PROJECT_DIR$" />
+ <package
value="github.com/apache/dubbo-go-samples/general/dubbo3/msgpack/go-server/cmd"
/>
+ <directory
value="github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd"
/>
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/general/dubbo3/codec-extension/go-client/cmd/client.go
b/general/dubbo3/codec-extension/go-client/cmd/client.go
new file mode 100644
index 0000000..2d9c42f
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-client/cmd/client.go
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+ "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/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"
+)
+
+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"
+)
+
+var userProvider = new(pkg.UserProvider)
+
+func init() {
+ config.SetConsumerService(userProvider)
+}
+
+// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to
"conf/client.yml" before run
+func main() {
+ config.Load()
+ 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)
+ if err != nil {
+ gxlog.CError("error: %v\n", err)
+ os.Exit(1)
+ return
+ }
+ gxlog.CInfo("response result: %v\n", user)
+}
diff --git a/general/dubbo3/codec-extension/go-client/codec/codec.go
b/general/dubbo3/codec-extension/go-client/codec/codec.go
new file mode 100644
index 0000000..34b1b24
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-client/codec/codec.go
@@ -0,0 +1,29 @@
+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/general/dubbo3/codec-extension/go-client/conf/client.yml
b/general/dubbo3/codec-extension/go-client/conf/client.yml
new file mode 100644
index 0000000..d4c14a2
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-client/conf/client.yml
@@ -0,0 +1,33 @@
+# 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/tengine/go-server/conf/log.yml
b/general/dubbo3/codec-extension/go-client/conf/log.yml
similarity index 96%
copy from tengine/go-server/conf/log.yml
copy to general/dubbo3/codec-extension/go-client/conf/log.yml
index a75bccb..8c3f700 100644
--- a/tengine/go-server/conf/log.yml
+++ b/general/dubbo3/codec-extension/go-client/conf/log.yml
@@ -1,5 +1,4 @@
-
-level: "error"
+level: "info"
development: true
disableCaller: false
disableStacktrace: false
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/codec-extension/go-client/pkg/hello.go
similarity index 67%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/codec-extension/go-client/pkg/hello.go
index c6d39de..da5c377 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/codec-extension/go-client/pkg/hello.go
@@ -20,38 +20,17 @@ package pkg
import (
"context"
)
-import (
- "github.com/dubbogo/gost/log"
-)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
-)
-
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
-}
type User struct {
- Id string
+ ID string
Name string
Age int32
}
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}
- gxlog.CInfo("rsp:%#v", rsp)
- return &rsp, nil
+ GetUser func(ctx context.Context, req *User, rsp *User) error
}
func (u *UserProvider) Reference() string {
return "UserProvider"
}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
-}
diff --git a/general/dubbo3/codec-extension/go-server/cmd/server.go
b/general/dubbo3/codec-extension/go-server/cmd/server.go
new file mode 100644
index 0000000..8e485a3
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-server/cmd/server.go
@@ -0,0 +1,83 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "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/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"
+)
+
+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)
+)
+
+func init() {
+ config.SetProviderService(new(pkg.UserProvider))
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ config.Load()
+ initSignal()
+}
+
+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)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git a/general/dubbo3/codec-extension/go-server/codec/codec.go
b/general/dubbo3/codec-extension/go-server/codec/codec.go
new file mode 100644
index 0000000..b4d42e6
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-server/codec/codec.go
@@ -0,0 +1,25 @@
+package codec
+
+import (
+ "encoding/json"
+ 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/general/dubbo3/codec-extension/go-server/conf/client.yml
b/general/dubbo3/codec-extension/go-server/conf/client.yml
new file mode 100644
index 0000000..137d8b2
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-server/conf/client.yml
@@ -0,0 +1,32 @@
+# 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/tengine/go-server/conf/log.yml
b/general/dubbo3/codec-extension/go-server/conf/log.yml
similarity index 96%
copy from tengine/go-server/conf/log.yml
copy to general/dubbo3/codec-extension/go-server/conf/log.yml
index a75bccb..8c3f700 100644
--- a/tengine/go-server/conf/log.yml
+++ b/general/dubbo3/codec-extension/go-server/conf/log.yml
@@ -1,5 +1,4 @@
-
-level: "error"
+level: "info"
development: true
disableCaller: false
disableStacktrace: false
diff --git a/general/dubbo3/codec-extension/go-server/conf/server.yml
b/general/dubbo3/codec-extension/go-server/conf/server.yml
new file mode 100644
index 0000000..4e8d051
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-server/conf/server.yml
@@ -0,0 +1,30 @@
+# 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/general/dubbo3/codec-extension/go-server/docker/docker-compose.yml
b/general/dubbo3/codec-extension/go-server/docker/docker-compose.yml
new file mode 100644
index 0000000..8724179
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-server/docker/docker-compose.yml
@@ -0,0 +1,9 @@
+version: '3'
+
+services:
+ zookeeper:
+ image: zookeeper
+ ports:
+ - 2181:2181
+ restart: on-failure
+
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/codec-extension/go-server/pkg/greeter.go
similarity index 73%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/codec-extension/go-server/pkg/greeter.go
index c6d39de..0013c02 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/codec-extension/go-server/pkg/greeter.go
@@ -23,17 +23,9 @@ import (
import (
"github.com/dubbogo/gost/log"
)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
-)
-
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
-}
type User struct {
- Id string
+ ID string
Name string
Age int32
}
@@ -41,9 +33,9 @@ type User struct {
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}
+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
}
@@ -51,7 +43,3 @@ func (u *UserProvider) GetUser(ctx context.Context, req
[]interface{}) (*User, e
func (u *UserProvider) Reference() string {
return "UserProvider"
}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
-}
diff --git
a/general/dubbo3/codec-extension/go-server/tests/integration/codec.go
b/general/dubbo3/codec-extension/go-server/tests/integration/codec.go
new file mode 100644
index 0000000..2e99237
--- /dev/null
+++ b/general/dubbo3/codec-extension/go-server/tests/integration/codec.go
@@ -0,0 +1,25 @@
+package integration
+
+import (
+ "encoding/json"
+ 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/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/codec-extension/go-server/tests/integration/main_test.go
similarity index 55%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/codec-extension/go-server/tests/integration/main_test.go
index c6d39de..3ea2fe6 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/codec-extension/go-server/tests/integration/main_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,43 +17,46 @@
* limitations under the License.
*/
-package pkg
+package integration
import (
"context"
+ "os"
+ "testing"
+ "time"
)
+
import (
- "github.com/dubbogo/gost/log"
-)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
+ _ "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/inmemory"
+ _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
)
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
+var userProvider = new(UserProvider)
+
+func TestMain(m *testing.M) {
+ config.SetConsumerService(userProvider)
+ config.Load()
+ time.Sleep(3 * time.Second)
+ os.Exit(m.Run())
}
type User struct {
- Id string
+ ID string
Name string
Age int32
}
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}
- gxlog.CInfo("rsp:%#v", rsp)
- return &rsp, nil
+ GetUser func(ctx context.Context, req *User, rsp *User) error
}
func (u *UserProvider) Reference() string {
return "UserProvider"
}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
-}
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/codec-extension/go-server/tests/integration/userprovider_test.go
similarity index 57%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to
general/dubbo3/codec-extension/go-server/tests/integration/userprovider_test.go
index c6d39de..7a08d19 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++
b/general/dubbo3/codec-extension/go-server/tests/integration/userprovider_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,43 +17,22 @@
* limitations under the License.
*/
-package pkg
+package integration
import (
"context"
+ "testing"
)
+
import (
- "github.com/dubbogo/gost/log"
-)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
+ "github.com/stretchr/testify/assert"
)
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
-}
-
-type User struct {
- Id string
- Name string
- Age int32
-}
-
-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}
- gxlog.CInfo("rsp:%#v", rsp)
- return &rsp, nil
-}
-
-func (u *UserProvider) Reference() string {
- return "UserProvider"
-}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
+func TestGetUser(t *testing.T) {
+ user := &User{}
+ err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"},
user)
+ assert.Nil(t, err)
+ assert.Equal(t, "12345", user.ID)
+ assert.Equal(t, "Hello laurence", user.Name)
+ assert.Equal(t, int32(18), user.Age)
}
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/hessian2/go-server/pkg/greeter.go
index c6d39de..8e1f7f6 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/hessian2/go-server/pkg/greeter.go
@@ -41,14 +41,14 @@ type User struct {
type UserProvider struct {
}
-func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User,
error) {
+func (u UserProvider) GetUser(ctx context.Context, req []interface{}) (*User,
error) {
gxlog.CInfo("req:%#v", req)
rsp := User{"A001", "Alex Stocks", 18}
gxlog.CInfo("rsp:%#v", rsp)
return &rsp, nil
}
-func (u *UserProvider) Reference() string {
+func (u UserProvider) Reference() string {
return "UserProvider"
}
diff --git a/general/dubbo3/msgpack/go-client/cmd/client.go
b/general/dubbo3/msgpack/go-client/cmd/client.go
new file mode 100644
index 0000000..cb0c755
--- /dev/null
+++ b/general/dubbo3/msgpack/go-client/cmd/client.go
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+ "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/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"
+)
+
+import (
+
"github.com/apache/dubbo-go-samples/general/dubbo3/msgpack/go-client/pkg"
+)
+
+var userProvider = new(pkg.UserProvider)
+
+func init() {
+ config.SetConsumerService(userProvider)
+}
+
+// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to
"conf/client.yml" before run
+func main() {
+ config.Load()
+ 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)
+ if err != nil {
+ gxlog.CError("error: %v\n", err)
+ os.Exit(1)
+ return
+ }
+ gxlog.CInfo("response result: %v\n", user)
+}
diff --git a/general/dubbo3/msgpack/go-client/conf/client.yml
b/general/dubbo3/msgpack/go-client/conf/client.yml
new file mode 100644
index 0000000..2a1082a
--- /dev/null
+++ b/general/dubbo3/msgpack/go-client/conf/client.yml
@@ -0,0 +1,33 @@
+# 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: "msgpack"
+# url: "dubbo://127.0.0.1:20000" # target server ip:port
+ interface: "com.apache.dubbo.sample.basic.IGreeter"
\ No newline at end of file
diff --git a/tengine/go-server/conf/log.yml
b/general/dubbo3/msgpack/go-client/conf/log.yml
similarity index 96%
copy from tengine/go-server/conf/log.yml
copy to general/dubbo3/msgpack/go-client/conf/log.yml
index a75bccb..8c3f700 100644
--- a/tengine/go-server/conf/log.yml
+++ b/general/dubbo3/msgpack/go-client/conf/log.yml
@@ -1,5 +1,4 @@
-
-level: "error"
+level: "info"
development: true
disableCaller: false
disableStacktrace: false
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/msgpack/go-client/pkg/hello.go
similarity index 67%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/msgpack/go-client/pkg/hello.go
index c6d39de..da5c377 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/msgpack/go-client/pkg/hello.go
@@ -20,38 +20,17 @@ package pkg
import (
"context"
)
-import (
- "github.com/dubbogo/gost/log"
-)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
-)
-
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
-}
type User struct {
- Id string
+ ID string
Name string
Age int32
}
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}
- gxlog.CInfo("rsp:%#v", rsp)
- return &rsp, nil
+ GetUser func(ctx context.Context, req *User, rsp *User) error
}
func (u *UserProvider) Reference() string {
return "UserProvider"
}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
-}
diff --git a/general/dubbo3/msgpack/go-server/cmd/server.go
b/general/dubbo3/msgpack/go-server/cmd/server.go
new file mode 100644
index 0000000..c31f0aa
--- /dev/null
+++ b/general/dubbo3/msgpack/go-server/cmd/server.go
@@ -0,0 +1,82 @@
+/*
+* 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"
+)
+
+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"
+)
+
+import (
+
"github.com/apache/dubbo-go-samples/general/dubbo3/msgpack/go-server/pkg"
+)
+
+var (
+ survivalTimeout = int(3 * time.Second)
+)
+
+func init() {
+ config.SetProviderService(new(pkg.UserProvider))
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ config.Load()
+ initSignal()
+}
+
+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)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git a/general/dubbo3/msgpack/go-server/conf/client.yml
b/general/dubbo3/msgpack/go-server/conf/client.yml
new file mode 100644
index 0000000..144bc66
--- /dev/null
+++ b/general/dubbo3/msgpack/go-server/conf/client.yml
@@ -0,0 +1,32 @@
+# 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: "msgpack"
+ interface: "com.apache.dubbo.sample.basic.IGreeter"
diff --git a/tengine/go-server/conf/log.yml
b/general/dubbo3/msgpack/go-server/conf/log.yml
similarity index 96%
copy from tengine/go-server/conf/log.yml
copy to general/dubbo3/msgpack/go-server/conf/log.yml
index a75bccb..8c3f700 100644
--- a/tengine/go-server/conf/log.yml
+++ b/general/dubbo3/msgpack/go-server/conf/log.yml
@@ -1,5 +1,4 @@
-
-level: "error"
+level: "info"
development: true
disableCaller: false
disableStacktrace: false
diff --git a/general/dubbo3/msgpack/go-server/conf/server.yml
b/general/dubbo3/msgpack/go-server/conf/server.yml
new file mode 100644
index 0000000..8ae95f6
--- /dev/null
+++ b/general/dubbo3/msgpack/go-server/conf/server.yml
@@ -0,0 +1,30 @@
+# 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: "msgpack" # msgpack is serialization type
+ interface: "com.apache.dubbo.sample.basic.IGreeter"
+
+# protocol config
+protocols:
+ "tri":
+ name: "tri"
+ port: 20001
\ No newline at end of file
diff --git a/general/dubbo3/msgpack/go-server/docker/docker-compose.yml
b/general/dubbo3/msgpack/go-server/docker/docker-compose.yml
new file mode 100644
index 0000000..8724179
--- /dev/null
+++ b/general/dubbo3/msgpack/go-server/docker/docker-compose.yml
@@ -0,0 +1,9 @@
+version: '3'
+
+services:
+ zookeeper:
+ image: zookeeper
+ ports:
+ - 2181:2181
+ restart: on-failure
+
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/msgpack/go-server/pkg/greeter.go
similarity index 70%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/msgpack/go-server/pkg/greeter.go
index c6d39de..5a48831 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/msgpack/go-server/pkg/greeter.go
@@ -23,17 +23,9 @@ import (
import (
"github.com/dubbogo/gost/log"
)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
-)
-
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
-}
type User struct {
- Id string
+ ID string
Name string
Age int32
}
@@ -41,17 +33,13 @@ type User struct {
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}
+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 {
+func (u UserProvider) Reference() string {
return "UserProvider"
}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
-}
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/msgpack/go-server/tests/integration/main_test.go
similarity index 55%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/msgpack/go-server/tests/integration/main_test.go
index c6d39de..3ea2fe6 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/msgpack/go-server/tests/integration/main_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,43 +17,46 @@
* limitations under the License.
*/
-package pkg
+package integration
import (
"context"
+ "os"
+ "testing"
+ "time"
)
+
import (
- "github.com/dubbogo/gost/log"
-)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
+ _ "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/inmemory"
+ _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
)
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
+var userProvider = new(UserProvider)
+
+func TestMain(m *testing.M) {
+ config.SetConsumerService(userProvider)
+ config.Load()
+ time.Sleep(3 * time.Second)
+ os.Exit(m.Run())
}
type User struct {
- Id string
+ ID string
Name string
Age int32
}
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}
- gxlog.CInfo("rsp:%#v", rsp)
- return &rsp, nil
+ GetUser func(ctx context.Context, req *User, rsp *User) error
}
func (u *UserProvider) Reference() string {
return "UserProvider"
}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
-}
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go
b/general/dubbo3/msgpack/go-server/tests/integration/userprovider_test.go
similarity index 57%
copy from general/dubbo3/hessian2/go-server/pkg/greeter.go
copy to general/dubbo3/msgpack/go-server/tests/integration/userprovider_test.go
index c6d39de..7a08d19 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/msgpack/go-server/tests/integration/userprovider_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,43 +17,22 @@
* limitations under the License.
*/
-package pkg
+package integration
import (
"context"
+ "testing"
)
+
import (
- "github.com/dubbogo/gost/log"
-)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
+ "github.com/stretchr/testify/assert"
)
-func init() {
- // ------for hessian2------
- hessian.RegisterPOJO(&User{})
-}
-
-type User struct {
- Id string
- Name string
- Age int32
-}
-
-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}
- gxlog.CInfo("rsp:%#v", rsp)
- return &rsp, nil
-}
-
-func (u *UserProvider) Reference() string {
- return "UserProvider"
-}
-
-func (u User) JavaClassName() string {
- return "com.apache.dubbo.sample.basic.User"
+func TestGetUser(t *testing.T) {
+ user := &User{}
+ err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"},
user)
+ assert.Nil(t, err)
+ assert.Equal(t, "12345", user.ID)
+ assert.Equal(t, "Hello laurence", user.Name)
+ assert.Equal(t, int32(18), user.Age)
}
diff --git a/go.mod b/go.mod
index e046c1b..10fa3a5 100644
--- a/go.mod
+++ b/go.mod
@@ -21,7 +21,7 @@ require (
github.com/uber/jaeger-client-go v2.22.1+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
golang.org/x/net v0.0.0-20201224014010-6772e930b67b
- google.golang.org/grpc v1.36.0
+ google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
)
diff --git a/go.sum b/go.sum
index 050c667..cbd7774 100644
--- a/go.sum
+++ b/go.sum
@@ -1117,8 +1117,9 @@ google.golang.org/grpc v1.27.0/go.mod
h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.29.1/go.mod
h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.32.0/go.mod
h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.33.1/go.mod
h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
-google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As=
google.golang.org/grpc v1.36.0/go.mod
h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0=
+google.golang.org/grpc v1.38.0/go.mod
h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod
h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod
h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod
h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index 82333ad..58a562b 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -31,6 +31,8 @@ array+=("filter/tpslimit/go-server")
array+=("filter/sentinel/go-server")
array+=("general/dubbo/go-server")
+array+=("general/dubbo3/codec-extension/go-server")
+array+=("general/dubbo3/msgpack/go-server")
array+=("generic/go-server")
@@ -51,6 +53,7 @@ array+=("registry/servicediscovery/zookeeper/go-server")
array+=("registry/servicediscovery/nacos/go-server")
+
for((i=0;i<${#array[*]};i++))
do
./integrate_test.sh ${array[i]}
@@ -58,4 +61,4 @@ do
if [ $result -gt 0 ]; then
exit $result
fi
-done
\ No newline at end of file
+done
diff --git a/tengine/go-server/conf/log.yml b/tengine/go-server/conf/log.yml
index a75bccb..8c3f700 100644
--- a/tengine/go-server/conf/log.yml
+++ b/tengine/go-server/conf/log.yml
@@ -1,5 +1,4 @@
-
-level: "error"
+level: "info"
development: true
disableCaller: false
disableStacktrace: false