Skip to content
Snippets Groups Projects
Commit 2624c775 authored by vito.he's avatar vito.he
Browse files

Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubbo into develop

parents d6ba7ffd 73becbba
No related branches found
No related tags found
No related merge requests found
Showing
with 46 additions and 51 deletions
......@@ -15,5 +15,5 @@ const (
)
const (
ECHO = "Echo"
ECHO = "$echo"
)
......@@ -10,7 +10,7 @@ import (
import (
"github.com/dubbo/go-for-apache-dubbo/common"
"github.com/dubbo/go-for-apache-dubbo/protocol"
"github.com/dubbo/go-for-apache-dubbo/protocol/invocation"
invocation_impl "github.com/dubbo/go-for-apache-dubbo/protocol/invocation"
)
// Proxy struct
......@@ -53,8 +53,12 @@ func (p *Proxy) Implement(v common.RPCService) {
makeDubboCallProxy := func(methodName string, outs []reflect.Type) func(in []reflect.Value) []reflect.Value {
return func(in []reflect.Value) []reflect.Value {
log.Info("call method!")
inv := invocation.NewRPCInvocationForConsumer(methodName, nil, in[1].Interface().([]interface{}), in[2].Interface(), p.callBack, common.URL{}, nil)
if methodName == "Echo" {
methodName = "$echo"
}
inv := invocation_impl.NewRPCInvocationForConsumer(methodName, nil, in[1].Interface().([]interface{}), in[2].Interface(), p.callBack, common.URL{}, nil)
for k, v := range p.attachments {
inv.SetAttachments(k, v)
}
......
......@@ -24,7 +24,7 @@ import (
_ "github.com/dubbo/go-for-apache-dubbo/protocol/dubbo"
_ "github.com/dubbo/go-for-apache-dubbo/registry/protocol"
_ "github.com/dubbo/go-for-apache-dubbo/filter/imp"
_ "github.com/dubbo/go-for-apache-dubbo/filter/impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
......
......@@ -22,7 +22,7 @@ import (
_ "github.com/dubbo/go-for-apache-dubbo/protocol/dubbo"
_ "github.com/dubbo/go-for-apache-dubbo/registry/protocol"
_ "github.com/dubbo/go-for-apache-dubbo/filter/imp"
_ "github.com/dubbo/go-for-apache-dubbo/filter/impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
......
......@@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"github.com/dubbo/go-for-apache-dubbo/config"
"net/http"
_ "net/http/pprof"
"os"
......@@ -20,13 +19,14 @@ import (
)
import (
"github.com/dubbo/go-for-apache-dubbo/config"
_ "github.com/dubbo/go-for-apache-dubbo/protocol/jsonrpc"
_ "github.com/dubbo/go-for-apache-dubbo/registry/protocol"
_ "github.com/dubbo/go-for-apache-dubbo/filter/imp"
_ "github.com/dubbo/go-for-apache-dubbo/filter/impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
_ "github.com/dubbo/go-for-apache-dubbo/registry/zookeeper"
)
......
......@@ -3,11 +3,11 @@ package main
import (
"context"
"fmt"
"github.com/dubbo/go-for-apache-dubbo/config"
)
import (
"github.com/AlexStocks/goext/time"
"github.com/dubbo/go-for-apache-dubbo/config"
)
func init() {
......
......@@ -20,7 +20,7 @@ import (
_ "github.com/dubbo/go-for-apache-dubbo/protocol/jsonrpc"
_ "github.com/dubbo/go-for-apache-dubbo/registry/protocol"
_ "github.com/dubbo/go-for-apache-dubbo/filter/imp"
_ "github.com/dubbo/go-for-apache-dubbo/filter/impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl"
......
......@@ -2,7 +2,6 @@ package main
import (
"fmt"
"github.com/dubbo/go-for-apache-dubbo/config"
"net/http"
_ "net/http/pprof"
"os"
......@@ -18,13 +17,14 @@ import (
)
import (
"github.com/dubbo/go-for-apache-dubbo/config"
_ "github.com/dubbo/go-for-apache-dubbo/protocol/jsonrpc"
_ "github.com/dubbo/go-for-apache-dubbo/registry/protocol"
_ "github.com/dubbo/go-for-apache-dubbo/filter/imp"
_ "github.com/dubbo/go-for-apache-dubbo/filter/impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl"
_ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
_ "github.com/dubbo/go-for-apache-dubbo/registry/zookeeper"
)
......
package main
import (
// "encoding/json"
"context"
"fmt"
"github.com/dubbo/go-for-apache-dubbo/config"
"time"
)
import (
"github.com/AlexStocks/goext/log"
"github.com/AlexStocks/goext/time"
"github.com/dubbo/go-for-apache-dubbo/config"
)
type Gender int
......
package imp
package impl
import (
log "github.com/AlexStocks/log4go"
......
package imp
package impl
import (
"testing"
......@@ -17,7 +17,7 @@ import (
func TestEchoFilter_Invoke(t *testing.T) {
filter := GetFilter()
result := filter.Invoke(protocol.NewBaseInvoker(common.URL{}),
invocation.NewRPCInvocationForProvider("Echo", []interface{}{"OK"}, nil))
invocation.NewRPCInvocationForProvider("$echo", []interface{}{"OK"}, nil))
assert.Equal(t, "OK", result.Result())
result = filter.Invoke(protocol.NewBaseInvoker(common.URL{}),
......
module github.com/dubbo/go-for-apache-dubbo
require (
github.com/AlexStocks/getty v0.0.0-20190513191741-cb811d1c31dd
github.com/AlexStocks/getty v0.0.0-20190513203438-4a52b6874223
github.com/AlexStocks/goext v0.3.2
github.com/AlexStocks/log4go v1.0.2
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/dubbogo/hessian2 v0.0.0-20190410112310-f093e4436e31
github.com/dubbogo/hessian2 v0.0.0-20190513195500-efce02944002
github.com/juju/errors v0.0.0-20190207033735-e65537c515d7
github.com/montanaflynn/stats v0.5.0
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275
......@@ -14,6 +12,5 @@ require (
github.com/stretchr/testify v1.3.0
github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5
go.uber.org/atomic v1.3.2
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/yaml.v2 v2.2.2
)
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/AlexStocks/getty v0.0.0-20190513191741-cb811d1c31dd h1:kLcmlBGDmo9S+VSmRnDTUFCq3wvlIh9CMd4zLWqY1+4=
github.com/AlexStocks/getty v0.0.0-20190513191741-cb811d1c31dd/go.mod h1:n25mdqPgFi06sWL6mZTjm1hBIZuKwgXUVXAX+KGB97U=
github.com/AlexStocks/getty v0.0.0-20190513203438-4a52b6874223 h1:3Sk5FwL8QpEHeJewYv4piyhOGOj2MS2Ev4S5tHTVSTo=
github.com/AlexStocks/getty v0.0.0-20190513203438-4a52b6874223/go.mod h1:n25mdqPgFi06sWL6mZTjm1hBIZuKwgXUVXAX+KGB97U=
github.com/AlexStocks/goext v0.3.2 h1:Bn4C+R6/E5Yjk2Uc/voawtbGv91x9aCid92xwYL2AS0=
github.com/AlexStocks/goext v0.3.2 h1:Bn4C+R6/E5Yjk2Uc/voawtbGv91x9aCid92xwYL2AS0=
github.com/AlexStocks/goext v0.3.2/go.mod h1:3M5j9Pjge4CdkNg2WIjRLUeoPedJHHKwkkglDGSl3Hc=
......@@ -8,10 +8,6 @@ github.com/AlexStocks/goext v0.3.2/go.mod h1:3M5j9Pjge4CdkNg2WIjRLUeoPedJHHKwkkg
github.com/AlexStocks/log4go v1.0.2 h1:1K5WM8KjSUECaoXUl8FSF05KGeCJDfBrhKUBsxwUvhk=
github.com/AlexStocks/log4go v1.0.2/go.mod h1:6kCCRo/orDo8mh5CEDOeuSSM674wBQ8M6E0K8dVOIz4=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
......@@ -28,8 +24,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dubbogo/hessian2 v0.0.0-20190410112310-f093e4436e31 h1:qgwFcVu63dt6cKbMICPQN3NKo6m9fC/6FdJbffnmXOU=
github.com/dubbogo/hessian2 v0.0.0-20190410112310-f093e4436e31/go.mod h1:v+gfInE8fm/k3Fjkb2oUCKSO9LKbWvf+PtweEI89BmI=
github.com/dubbogo/hessian2 v0.0.0-20190513195500-efce02944002 h1:qtXH4fHzFh1ezGWIdVrfIYxbaCUqbDpUwu2xIjnkw6I=
github.com/dubbogo/hessian2 v0.0.0-20190513195500-efce02944002/go.mod h1:v+gfInE8fm/k3Fjkb2oUCKSO9LKbWvf+PtweEI89BmI=
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
......@@ -160,8 +156,6 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
......
......@@ -278,10 +278,10 @@ func (c *Client) transfer(session getty.Session, pkg *DubboPackage,
if pkg == nil {
pkg = &DubboPackage{}
pkg.Body = []interface{}{}
pkg.Header.Type = hessian.Heartbeat
pkg.Header.Type = hessian.PackageHeartbeat
pkg.Header.SerialID = byte(S_Dubbo)
} else {
pkg.Header.Type = hessian.Request
pkg.Header.Type = hessian.PackageRequest
}
pkg.Header.ID = int64(sequence)
......
......@@ -78,7 +78,7 @@ func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error {
}
}
if p.Header.Type&hessian.Heartbeat != 0x00 {
if p.Header.Type&hessian.PackageHeartbeat != 0x00 {
return nil
}
......
......@@ -2,6 +2,7 @@ package dubbo
import (
"context"
"errors"
"reflect"
"sync"
"time"
......@@ -67,7 +68,7 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) {
return
}
if p.Header.Type&hessian.Heartbeat != 0x00 {
if p.Header.Type&hessian.PackageHeartbeat != 0x00 {
log.Debug("get rpc heartbeat response{header: %#v, body: %#v}", p.Header, p.Body)
return
}
......@@ -176,15 +177,15 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
p.Header.ResponseStatus = hessian.Response_OK
// heartbeat
if p.Header.Type&hessian.Heartbeat != 0x00 {
if p.Header.Type&hessian.PackageHeartbeat != 0x00 {
log.Debug("get rpc heartbeat request{header: %#v, service: %#v, body: %#v}", p.Header, p.Service, p.Body)
h.reply(session, p, hessian.Heartbeat)
h.reply(session, p, hessian.PackageHeartbeat)
return
}
// not twoway
if p.Header.Type&hessian.Request_TwoWay == 0x00 {
h.reply(session, p, hessian.Response)
if p.Header.Type&hessian.PackageRequest_TwoWay == 0x00 {
h.reply(session, p, hessian.PackageResponse)
h.callService(p, nil)
return
}
......@@ -200,19 +201,19 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
if err := result.Error(); err != nil {
p.Header.ResponseStatus = hessian.Response_SERVER_ERROR
p.Body = err
h.reply(session, p, hessian.Response)
h.reply(session, p, hessian.PackageResponse)
return
}
if res := result.Result(); res != nil {
p.Header.ResponseStatus = hessian.Response_OK
p.Body = res
h.reply(session, p, hessian.Response)
h.reply(session, p, hessian.PackageResponse)
return
}
}
h.callService(p, nil)
h.reply(session, p, hessian.Response)
h.reply(session, p, hessian.PackageResponse)
}
func (h *RpcServerHandler) OnCron(session getty.Session) {
......@@ -262,7 +263,7 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) {
if svcIf == nil {
log.Error("service not found!")
req.Header.ResponseStatus = hessian.Response_SERVICE_NOT_FOUND
req.Body = nil
req.Body = errors.New("service not found")
return
}
svc := svcIf.(*common.Service)
......@@ -270,7 +271,7 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) {
if method == nil {
log.Error("method not found!")
req.Header.ResponseStatus = hessian.Response_SERVICE_NOT_FOUND
req.Body = nil
req.Body = errors.New("method not found")
return
}
......@@ -311,7 +312,7 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) {
}
}
func (h *RpcServerHandler) reply(session getty.Session, req *DubboPackage, tp hessian.PackgeType) {
func (h *RpcServerHandler) reply(session getty.Session, req *DubboPackage, tp hessian.PackageType) {
resp := &DubboPackage{
Header: hessian.DubboHeader{
SerialID: req.Header.SerialID,
......@@ -321,7 +322,7 @@ func (h *RpcServerHandler) reply(session getty.Session, req *DubboPackage, tp he
},
}
if req.Header.Type&hessian.Request != 0x00 {
if req.Header.Type&hessian.PackageRequest != 0x00 {
resp.Body = req.Body
} else {
resp.Body = nil
......
......@@ -9,7 +9,7 @@ import (
"github.com/dubbo/go-for-apache-dubbo/common/constant"
"github.com/dubbo/go-for-apache-dubbo/common/extension"
"github.com/dubbo/go-for-apache-dubbo/filter"
"github.com/dubbo/go-for-apache-dubbo/filter/imp"
"github.com/dubbo/go-for-apache-dubbo/filter/impl"
"github.com/dubbo/go-for-apache-dubbo/protocol"
)
......@@ -49,7 +49,7 @@ func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
filtName = filtName + ","
}
if key == constant.SERVICE_FILTER_KEY { // echofilter must be the first in provider
filtName = imp.ECHO + "," + filtName
filtName = impl.ECHO + "," + filtName
}
filtNames := strings.Split(filtName, ",")
next := invoker
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment