Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftr: Triple Protocol Support #1071

Merged
merged 45 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
789d3b0
ftr: add triple support
LaurenceLiZhixin Mar 1, 2021
8ebf52e
fix: change name
LaurenceLiZhixin Mar 1, 2021
b0bd3d8
Fix: delete unused replace
LaurenceLiZhixin Mar 1, 2021
e0e2993
fix: go fmt
LaurenceLiZhixin Mar 1, 2021
72ae2c1
fix
LaurenceLiZhixin Mar 1, 2021
72e91db
fix: dependency bug
LaurenceLiZhixin Mar 2, 2021
3aa8f1c
fix: dependency bug
LaurenceLiZhixin Mar 2, 2021
e930603
fix: add gen-dubbo3 go mod to pass ci
LaurenceLiZhixin Mar 2, 2021
c5fcc1f
Fix: fix ci lint
LaurenceLiZhixin Mar 2, 2021
956e382
fix: change ci go-version
LaurenceLiZhixin Mar 2, 2021
a96927f
fix: add liscense
LaurenceLiZhixin Mar 2, 2021
3466d14
Fix: change gost version
LaurenceLiZhixin Mar 2, 2021
83ff336
fix: fix cr
LaurenceLiZhixin Mar 7, 2021
7553e83
fix: destroy invoker smoothly
LaurenceLiZhixin Mar 8, 2021
57b92f9
fix: change triple struct
LaurenceLiZhixin Mar 14, 2021
53799e8
Fix: change triple api and add test file
LaurenceLiZhixin Mar 18, 2021
bbc9af2
fix: fix ci
LaurenceLiZhixin Mar 18, 2021
c1f9073
fix: change ctx key type
LaurenceLiZhixin Mar 18, 2021
98100e8
fix: fix linter
LaurenceLiZhixin Mar 18, 2021
c5e638d
fix: fix linter
LaurenceLiZhixin Mar 18, 2021
1d0f9fc
fix: add liscense
LaurenceLiZhixin Mar 18, 2021
95e0460
Fix: fix test
LaurenceLiZhixin Mar 18, 2021
90e3a32
fix: change port
LaurenceLiZhixin Mar 18, 2021
b37dd9f
fix: change port
LaurenceLiZhixin Mar 18, 2021
25cdffb
fix: change port
LaurenceLiZhixin Mar 18, 2021
31d9cd2
fix: change lock range
LaurenceLiZhixin Mar 18, 2021
e4f7549
Fix: delete debug
LaurenceLiZhixin Mar 19, 2021
5a359fa
fix: restart ci
LaurenceLiZhixin Mar 19, 2021
4152114
fix: fix test
LaurenceLiZhixin Mar 19, 2021
a7a2c30
fix: add serializer option
LaurenceLiZhixin Mar 26, 2021
fb540d9
fix: change triple
LaurenceLiZhixin Mar 26, 2021
3452103
fixï: add hessian support
LaurenceLiZhixin Apr 2, 2021
d785615
feat: add triple hessian support
LaurenceLiZhixin Apr 2, 2021
6a76922
fix: change go mod
LaurenceLiZhixin Apr 2, 2021
69136b3
fix: change consul
LaurenceLiZhixin Apr 2, 2021
00ae936
fix: triple finish
LaurenceLiZhixin Apr 3, 2021
e8bad05
fix: fix import block
LaurenceLiZhixin Apr 3, 2021
8b5ac5d
fix: restart ci
LaurenceLiZhixin Apr 3, 2021
5a5103b
fix: restart ci
LaurenceLiZhixin Apr 3, 2021
36fc244
fix: restart ci
LaurenceLiZhixin Apr 3, 2021
9202654
fix: update golang ci
LaurenceLiZhixin Apr 3, 2021
6ff62af
fix: fix conflict
LaurenceLiZhixin Apr 3, 2021
72abb01
fix: fix zk import
LaurenceLiZhixin Apr 3, 2021
9b0e5ea
fix: change ci lint vesion
LaurenceLiZhixin Apr 3, 2021
2d54f5c
fix: conflict
LaurenceLiZhixin Apr 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# If you want to matrix build , you can append the following list.
matrix:
go_version:
- 1.13
- 1.15
AlexStocks marked this conversation as resolved.
Show resolved Hide resolved
os:
- ubuntu-latest

Expand Down
1 change: 0 additions & 1 deletion config/config_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func TestNewProviderConfig(t *testing.T) {
WithProviderServices("UserProvider", serviceConfig),
WithProviderProtocol("dubbo", "dubbo", "20000"),
WithProviderRegistry("demoConsul", defaultConsulRegistry),
WithProviderRegistry("demoNacos", defaultNacosRegistry),
)

assert.NotNil(t, testProviderConfig.Services)
Expand Down
17 changes: 12 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/apache/dubbo-go
go 1.15

require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/RoaringBitmap/roaring v0.5.5
github.com/Workiva/go-datastructures v1.0.52
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
Expand All @@ -13,42 +14,48 @@ require (
github.com/creasty/defaults v1.5.1
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.3
github.com/dubbogo/triple v0.0.0-20210403061850-372f2dc47e02
github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.4.0
github.com/frankban/quicktest v1.4.1 // indirect
github.com/fsnotify/fsnotify v1.4.9
github.com/go-co-op/gocron v0.1.1
github.com/go-resty/resty/v2 v2.3.0
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.3
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/consul v1.8.0
github.com/hashicorp/consul/api v1.5.0
github.com/hashicorp/vault/sdk v0.1.14-0.20191112033314-390e96e22eb2
github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a // indirect
github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff // indirect
github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267
github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8
github.com/magiconair/properties v1.8.5
github.com/mitchellh/mapstructure v1.4.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/nacos-group/nacos-sdk-go v1.0.7
github.com/opentracing/opentracing-go v1.2.0
github.com/pierrec/lz4 v2.2.6+incompatible // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.9.0
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/zouyx/agollo/v3 v3.4.5
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.16.0
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
google.golang.org/grpc v1.33.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.16.9
k8s.io/apimachinery v0.16.9
k8s.io/client-go v0.16.9
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect
)

replace (
github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.4
github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.0
github.com/shirou/gopsutil => github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880
go.etcd.io/bbolt v1.3.4 => github.com/coreos/bbolt v1.3.3
google.golang.org/grpc v1.33.1 => google.golang.org/grpc v1.26.0
go.etcd.io/bbolt v1.3.4 => github.com/coreos/bbolt v1.3.4
google.golang.org/grpc => google.golang.org/grpc v1.26.0
)
84 changes: 54 additions & 30 deletions go.sum

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions protocol/dubbo3/common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* 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 dubbo3

import (
"context"
"fmt"
)

import (
triCommon "github.com/dubbogo/triple/pkg/common"
native_grpc "google.golang.org/grpc"
)

import (
"github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/dubbo3/internal"
"github.com/apache/dubbo-go/protocol/invocation"
)

// userd dubbo3 biz service
func addService() {
config.SetProviderService(newGreeterProvider())
}

type greeterProvider struct {
*greeterProviderBase
}

func newGreeterProvider() *greeterProvider {
return &greeterProvider{
greeterProviderBase: &greeterProviderBase{},
}
}

func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloRequest) (reply *internal.HelloReply, err error) {
fmt.Printf("req: %v", req)
return &internal.HelloReply{Message: "this is message from reply"}, nil
}

func (g *greeterProvider) Reference() string {
return "DubboGreeterImpl"
}

// code generated by greeter.go
type greeterProviderBase struct {
proxyImpl protocol.Invoker
}

func (g *greeterProviderBase) SetProxyImpl(impl protocol.Invoker) {
g.proxyImpl = impl
}

func (g *greeterProviderBase) GetProxyImpl() protocol.Invoker {
return g.proxyImpl
}

func (g *greeterProviderBase) ServiceDesc() *native_grpc.ServiceDesc {
return &native_grpc.ServiceDesc{
ServiceName: "helloworld.Greeter",
HandlerType: (*internal.GreeterServer)(nil),
Methods: []native_grpc.MethodDesc{
{
MethodName: "SayHello",
Handler: dubboGreeterSayHelloHandler,
},
},
Streams: []native_grpc.StreamDesc{},
Metadata: "helloworld.proto",
}
}

func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context,
dec func(interface{}) error, interceptor native_grpc.UnaryServerInterceptor) (interface{}, error) {

in := new(internal.HelloRequest)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(triCommon.Dubbo3GrpcService)

args := []interface{}{}
args = append(args, in)
invo := invocation.NewRPCInvocation("SayHello", args, nil)

if interceptor == nil {
result := base.GetProxyImpl().Invoke(context.Background(), invo)
return result.Result(), result.Error()
}
info := &native_grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.Greeter/SayHello",
}
handler := func(context.Context, interface{}) (interface{}, error) {
result := base.GetProxyImpl().Invoke(context.Background(), invo)
return result.Result(), result.Error()
}
return interceptor(ctx, in, info, handler)
}
61 changes: 61 additions & 0 deletions protocol/dubbo3/dubbo3_exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 dubbo3

import (
"sync"
)

import (
tripleCommon "github.com/dubbogo/triple/pkg/common"
)

import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol"
)

// DubboExporter is dubbo3 service exporter.
type DubboExporter struct {
protocol.BaseExporter
// serviceMap
serviceMap *sync.Map
}

// NewDubboExporter get a Dubbo3Exporter.
func NewDubboExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map, serviceMap *sync.Map) *DubboExporter {
return &DubboExporter{
BaseExporter: *protocol.NewBaseExporter(key, invoker, exporterMap),
serviceMap: serviceMap,
}
}

// Unexport unexport dubbo3 service exporter.
func (de *DubboExporter) Unexport() {
url := de.GetInvoker().GetUrl()
serviceId := url.GetParam(constant.BEAN_NAME_KEY, "")
interfaceName := url.GetParam(constant.INTERFACE_KEY, "")
de.BaseExporter.Unexport()
err := common.ServiceMap.UnRegister(interfaceName, tripleCommon.TRIPLE, serviceId)
if err != nil {
logger.Errorf("[DubboExporter.Unexport] error: %v", err)
}
de.serviceMap.Delete(interfaceName)
}
Loading