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

Rft: refactoring code #55

Merged
merged 175 commits into from
May 25, 2019
Merged
Changes from 2 commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
251a38c
Add&Mod: new structure
fangyincheng Apr 18, 2019
335c6ab
config
hxmhlt Apr 19, 2019
40b3c70
Ftr:1.0 add consumer config
hxmhlt Apr 19, 2019
34ad782
Add:add server of dubbo protocol
fangyincheng Apr 19, 2019
90dc527
config url cancel interface
hxmhlt Apr 19, 2019
c1f2b4a
config url cancel interface
hxmhlt Apr 19, 2019
5ac8246
Ftr:2.6.0 url rerwite & registry
hxmhlt Apr 22, 2019
067786d
Add:protocol
fangyincheng Apr 23, 2019
b513f20
Ftr:2.6.0 registry & cluster
hxmhlt Apr 23, 2019
c22cdcb
Ftr:2.6.0 conflict resolve
hxmhlt Apr 23, 2019
88af7eb
Fix:merge
fangyincheng Apr 23, 2019
a35e160
Rft:protocol/dubbo done.
fangyincheng Apr 25, 2019
713639e
Add:2.6.0 cluster & registry, context.Context in IURL
hxmhlt Apr 26, 2019
af4a03f
Add:conflicts resolve
hxmhlt Apr 26, 2019
ad8a392
Add:add ctx argument
fangyincheng Apr 26, 2019
be7294c
Ftr:complete protocol(dubbo & jsonrpc)
fangyincheng Apr 26, 2019
96b55e2
Add:2.6.0 cluster & registry
hxmhlt Apr 26, 2019
9dd22c7
Merge branch 'develop-1.0' of https://github.com/dubbogo/dubbo-go int…
hxmhlt Apr 26, 2019
4fb0a65
Add:2.6.0 cluster & registry
hxmhlt Apr 26, 2019
5de3b9a
Add:2.6.0 random loadbalance & failover cluster finish
hxmhlt Apr 28, 2019
0738aed
Ftr:proxy
fangyincheng Apr 28, 2019
f231b43
Add:2.6.0 import format
hxmhlt Apr 28, 2019
4769c5c
Merge branch 'develop-1.0' into develop-2.6.0
hxmhlt Apr 28, 2019
c92ac9e
Add:2.6.0 reference_config.Refer
hxmhlt Apr 28, 2019
10d89a5
Add:add proxy in reference_config
fangyincheng Apr 28, 2019
31dba4e
Rem:delete publi
fangyincheng Apr 28, 2019
4bbc711
Add:2.6.0 finish registryProtocol export
hxmhlt Apr 29, 2019
124bc37
Merge branch 'develop-2.6.0' of https://github.com/dubbogo/dubbo-go i…
hxmhlt Apr 29, 2019
d68c44e
Tst&Fix: add dubbo protocol test and fix bug
fangyincheng Apr 29, 2019
96a1206
Merge branch 'develop-2.6.0' of https://github.com/dubbogo/dubbo-go i…
fangyincheng Apr 29, 2019
a4534d9
Add:add EchoFilter and configuration initialization
fangyincheng Apr 29, 2019
9bb41cf
Fix:fix bug
fangyincheng Apr 29, 2019
bf36b06
Add:2.6.0 serviceConfig.Export &Implement
hxmhlt Apr 29, 2019
3f151c1
Tst:add jsonrpc protocol test
fangyincheng Apr 29, 2019
28a9f8c
Add:2.6.0 referenceConfig mod
hxmhlt Apr 29, 2019
ebedbf2
Merge branch 'develop-2.6.0' of https://github.com/dubbogo/dubbo-go i…
hxmhlt Apr 29, 2019
45ff270
Mod:add comment and log
fangyincheng Apr 29, 2019
22202f8
Merge branch 'develop-2.6.0' of https://github.com/dubbogo/dubbo-go i…
fangyincheng Apr 29, 2019
f6b1d6a
Add:2.6.0 application config mod
hxmhlt Apr 29, 2019
4fc5c5b
Merge branch 'develop-2.6.0' of https://github.com/dubbogo/dubbo-go i…
hxmhlt Apr 29, 2019
0ef1b75
Add:add Load()
fangyincheng Apr 30, 2019
33646c2
Add:2.6.0 move group,version into URL.params && remove registryUrl/IURL
hxmhlt Apr 30, 2019
4fea11b
Add:resolve conflict
hxmhlt Apr 30, 2019
0d91dfc
Add:multi registry support && URL modify
hxmhlt Apr 30, 2019
2b5747e
Add:multi registry support && URL modify
hxmhlt Apr 30, 2019
328eed9
Mod:fields in reference config & service config tranlate to lowcase:
hxmhlt Apr 30, 2019
9afa589
Mod:timeout clear & only registry url used timeout in params
hxmhlt Apr 30, 2019
178cf96
Mod:timeout clear & only registry url used timeout in params
hxmhlt Apr 30, 2019
3b0cb6a
Tst:proxy_test & rpc_service_test
fangyincheng Apr 30, 2019
289a9cd
Fix:fix bug
fangyincheng May 5, 2019
3c5015a
Add:2.6.0 add registry type
hxmhlt May 5, 2019
58b5556
Fix:fix bug
fangyincheng May 5, 2019
d18be63
Fix:bounds cache
hxmhlt May 5, 2019
71c0f73
Add:example/jsonrpc/go-server
fangyincheng May 5, 2019
22aa599
Fix:fix bug
fangyincheng May 5, 2019
11dd509
Mod:2.6.0 cancel service in url
hxmhlt May 5, 2019
50c7812
Add:2.6.0 interface in urlmap
hxmhlt May 5, 2019
8fd7ca7
Fix:fix bug
fangyincheng May 5, 2019
b73976d
Add:2.6.0 fix bug
hxmhlt May 5, 2019
7d09b03
Add:2.6.0 conflicts resolve
hxmhlt May 5, 2019
75cfe40
Fix:fix bug
fangyincheng May 5, 2019
28fe7e4
Add:2.6.0
hxmhlt May 5, 2019
df162aa
Fix:fix bug & example/jsonrpc ok
fangyincheng May 5, 2019
56a0300
Fix&Add:finish example & fix bug
fangyincheng May 6, 2019
cdf8615
Add:2.6.0 registry directory ut & destroy func & bug fix in zk.registry
hxmhlt May 6, 2019
9a5c0e8
Fix: zk registry params deep copy
hxmhlt May 6, 2019
1477356
Mod:formatting
fangyincheng May 6, 2019
189262f
Mod:dubbo-go -> go-for-apache-dubbo
fangyincheng May 6, 2019
c236c87
Add: mock registry fix
hxmhlt May 6, 2019
20b9e42
Fix:version to 2.6.0
hxmhlt May 6, 2019
7072679
Merge pull request #41 from dubbogo/develop-2.6.0
hxmhlt May 6, 2019
b16ddfa
Fix: fix multi registry register bug
hxmhlt May 6, 2019
f60ba2c
Fix:bug#42
hxmhlt May 6, 2019
6c99ca9
Merge pull request #43 from dubbogo/develop-2.6.0
hxmhlt May 7, 2019
15a5b62
Add&Fix:add Echo in example & fix 'no result after filter'
fangyincheng May 7, 2019
0e36886
Merge pull request #45 from fangyincheng/develop
hxmhlt May 7, 2019
f925991
Tst:add tests
fangyincheng May 7, 2019
060e765
Add:benchmark test
hxmhlt May 7, 2019
dc2d0b8
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 7, 2019
fd0bb1e
Fix:fix dubbo protocol bug
fangyincheng May 7, 2019
124585b
Merge pull request #46 from fangyincheng/develop
fangyincheng May 7, 2019
7460c1c
Add&Rem:add ProtocolConf & delete CONF_DUBBO_CLIENT_FILE_PATH/CONF_DU…
fangyincheng May 7, 2019
5edf3cc
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 7, 2019
ecfbdc0
Fix:fix bug
fangyincheng May 8, 2019
41242b4
Mod:formatting & imporoving
fangyincheng May 8, 2019
127163d
Fix:zk bug
hxmhlt May 8, 2019
cb872d9
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 8, 2019
6b0dfda
Imp:improving
fangyincheng May 8, 2019
7ff8157
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 8, 2019
dc262fb
Fix:192.168.56.1->127.0.0.1
fangyincheng May 8, 2019
a8ac241
Fix:fix bug about config
fangyincheng May 10, 2019
d325583
Fix:fix bug
fangyincheng May 11, 2019
f273fd4
Fix:fix bug about concurrency
fangyincheng May 13, 2019
86d0905
Add: unit test for registry finish
hxmhlt May 13, 2019
7591758
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 13, 2019
520531c
Mod:unit test mod
hxmhlt May 13, 2019
a516010
Mod:rename some package's name
hxmhlt May 14, 2019
2add397
Mod:format import
hxmhlt May 14, 2019
5b02ffe
Mod:registry dir ut
hxmhlt May 14, 2019
1387fff
Mod:registry dir ut
hxmhlt May 14, 2019
62cc50a
Mod:cluster some rename & fix a bug in registryDirectory
hxmhlt May 14, 2019
01e16d7
Mod:some struct and func to lowercase
hxmhlt May 14, 2019
6db6c9d
Dep&Fix:update hessian2 & change filter/imp to filter/impl
fangyincheng May 14, 2019
f63b150
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 14, 2019
73becbb
Fix:fix bug about test
fangyincheng May 14, 2019
d6ba7ff
Add: cluster unit test
hxmhlt May 14, 2019
2624c77
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 14, 2019
1a95a30
Del:remove benchmark
hxmhlt May 14, 2019
4f6a98f
Tst:test for common
fangyincheng May 15, 2019
9cd84a2
Add:unit test config
hxmhlt May 15, 2019
cbd0533
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 15, 2019
535d719
Tst:add test for protocol/jsonrpc
fangyincheng May 15, 2019
d856a98
Rem:removing .scannerwork & sonar-project.properties
fangyincheng May 15, 2019
90852c9
Dep:update hessian2
fangyincheng May 15, 2019
bc4f10f
Mod:formatting error of 'nil pointer'
fangyincheng May 15, 2019
51e3758
Add:add serviceMap unregister
fangyincheng May 16, 2019
96100ba
Fix: log bug in checkInvokers
hxmhlt May 16, 2019
9f65c6f
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 16, 2019
2a2af83
Fix:bug #42
hxmhlt May 16, 2019
f0f69ab
Mod:readme
hxmhlt May 16, 2019
acdd875
Update README.md
hxmhlt May 16, 2019
8874f03
Update README.md
hxmhlt May 16, 2019
2ae623b
Update README.md
hxmhlt May 16, 2019
90590be
Update README.md
hxmhlt May 16, 2019
d888633
Update README.md
hxmhlt May 16, 2019
e8f0f97
Tst:add test
fangyincheng May 16, 2019
4ebd55f
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 16, 2019
2565b40
Add:add examples/README.md
fangyincheng May 17, 2019
ebece39
Tst&Mod:add test & formatting code
fangyincheng May 17, 2019
833ca18
Add:add travis
fangyincheng May 17, 2019
b78fe92
Upd: improve feature list
May 19, 2019
9e6a479
Add: contribution notes
AlexStocks May 19, 2019
32cf1c8
Add:add check configuration for client
hxmhlt May 20, 2019
16906cd
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 20, 2019
f5d28e1
Update README.md
hxmhlt May 20, 2019
8e5724a
Update README.md
hxmhlt May 20, 2019
8b798ec
Mod:change to uber-go/atomic
hxmhlt May 20, 2019
b24c098
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 20, 2019
ea2f7ea
Imp:modify scripts of examples
fangyincheng May 20, 2019
c50891c
Imp: add log code style
AlexStocks May 20, 2019
20aed73
Imp:fix problems
fangyincheng May 20, 2019
8d49a06
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 20, 2019
afa419f
Add:add lowercase function & update examples
fangyincheng May 20, 2019
ba7c682
Imp:modify calling mode of client
fangyincheng May 21, 2019
ca33a9a
Add:add license
fangyincheng May 21, 2019
b7a0747
Dep:change github.com/juju/errors to github.com/pkg/errors
fangyincheng May 21, 2019
b468c84
Fix:problem about twoway
fangyincheng May 21, 2019
02a67cb
Mod:del goext & format code
fangyincheng May 22, 2019
3d39423
Add & Rft: add proxy_factory & refactor the extension
hxmhlt May 22, 2019
c61a592
Mod: update readme
hxmhlt May 22, 2019
f47311d
Mod: update readme
hxmhlt May 22, 2019
ba5dca3
Update README.md
hxmhlt May 22, 2019
336c50c
Rft:refactor filter
fangyincheng May 22, 2019
19f2531
Mrg:merge
fangyincheng May 22, 2019
0df1704
Fix:bug about mergeUrl
hxmhlt May 22, 2019
433b6b0
Mod:pkg/errors & format
fangyincheng May 22, 2019
c99383b
update created time
NameHaibinZhang May 23, 2019
77de209
Merge pull request #54 from NameHaibinZhang/develop
fangyincheng May 23, 2019
0ac0a4a
Imp:modify calling mode of server
fangyincheng May 23, 2019
22458df
Mod:update hessian2
fangyincheng May 23, 2019
dd3dcc5
Fix: nil pointer panic when consumer.reference.invoker is nil
hxmhlt May 23, 2019
55c86f7
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 23, 2019
a89f93c
Mod:change method name
fangyincheng May 23, 2019
4c3834b
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 23, 2019
7da68d8
Fix: nil pointer panic when consumer.reference.invoker is nil
hxmhlt May 23, 2019
d670a33
Merge branch 'develop' of https://github.com/dubbo/go-for-apache-dubb…
hxmhlt May 23, 2019
d83a309
Fix: error return msg not include service name
hxmhlt May 23, 2019
29a1e5e
Rem:delete pprof
fangyincheng May 23, 2019
57009c9
Merge remote-tracking branch 'upstream/develop' into develop
fangyincheng May 23, 2019
d29c725
Mod:upgrade getty
fangyincheng May 23, 2019
41ee655
Mod: change log4go to zap
fangyincheng May 24, 2019
602a3da
Fix:support []interface{}
fangyincheng May 25, 2019
c73bad2
Mod:update readme and travis
fangyincheng May 25, 2019
ba34672
Mrg:merge develog
fangyincheng May 25, 2019
8962cdd
Mod:update readme
fangyincheng May 25, 2019
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
1 change: 0 additions & 1 deletion cluster/cluster.go
Original file line number Diff line number Diff line change
@@ -5,4 +5,3 @@ import "github.com/dubbo/dubbo-go/protocol"
type Cluster interface {
Join(Directory) protocol.Invoker
}

4 changes: 4 additions & 0 deletions common/constant/key.go
Original file line number Diff line number Diff line change
@@ -27,3 +27,7 @@ const (
WARMUP_KEY = "warmup"
RETRIES_KEY = "retries"
)

const (
DUBBOGO_CTX_KEY = "dubbogo-ctx"
)
Empty file removed common/proxy/.gitkeep
Empty file.
108 changes: 108 additions & 0 deletions common/proxy/proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package proxy

import (
"fmt"
"reflect"
)
import (
log "github.com/AlexStocks/log4go"
)

import (
"github.com/dubbo/dubbo-go/protocol"
)

// Proxy struct
type Proxy struct {
v interface{}
invoke protocol.Invoker
callBack interface{}
attachments map[string]string
}

var typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type()

func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[string]string) *Proxy {
return &Proxy{
invoke: invoke,
callBack: callBack,
attachments: attachments,
}
}

// proxy implement
func (p *Proxy) Implement(v interface{}) error {

// check parameters, incoming interface must be a elem's pointer.
valueOf := reflect.ValueOf(v)
log.Debug("[Implement] reflect.TypeOf: %s", valueOf.String())
if valueOf.Kind() != reflect.Ptr {
return fmt.Errorf("%s must be a pointer", valueOf)
}

valueOfElem := valueOf.Elem()
typeOf := valueOfElem.Type()

// check incoming interface, incoming interface's elem must be a struct.
if typeOf.Kind() != reflect.Struct {
return fmt.Errorf("%s must be a struct ptr", valueOf.String())
}

makeDubboCallProxy := func(methodName string, outs []reflect.Type) func(in []reflect.Value) []reflect.Value {
return func(in []reflect.Value) []reflect.Value {
// Convert input parameters to interface.
var argsInterface = make([]interface{}, len(in))
for k, v := range in {
argsInterface[k] = v.Interface()
}

//todo:call
inv := protocol.NewRPCInvocationForConsumer(methodName, nil, argsInterface, in[2].Interface(), p.callBack, p.attachments, nil)
result := p.invoke.Invoke(inv)
var err error
err = result.Error()
return []reflect.Value{reflect.ValueOf(&err).Elem()}
}
}

numField := valueOfElem.NumField()
for i := 0; i < numField; i++ {
t := typeOf.Field(i)
f := valueOfElem.Field(i)
if f.Kind() == reflect.Func && f.IsValid() && f.CanSet() {

if t.Type.NumIn() != 3 && t.Type.NumIn() != 4 {
log.Error("method %s of mtype %v has wrong number of in parameters %d; needs exactly 3/4",
t.Name, t.Type.String(), t.Type.NumIn())
return fmt.Errorf("method %s of mtype %v has wrong number of in parameters %d; needs exactly 3/4",
t.Name, t.Type.String(), t.Type.NumIn())
}

// Method needs one out.
if t.Type.NumOut() != 1 {
log.Error("method %q has %d out parameters; needs exactly 1", t.Name, t.Type.NumOut())
return fmt.Errorf("method %q has %d out parameters; needs exactly 1", t.Name, t.Type.NumOut())
}
// The return type of the method must be error.
if returnType := t.Type.Out(0); returnType != typError {
log.Error("return type %s of method %q is not error", returnType, t.Name)
return fmt.Errorf("return type %s of method %q is not error", returnType, t.Name)
}

var funcOuts = make([]reflect.Type, t.Type.NumOut())
funcOuts[i] = t.Type.Out(0)

// do method proxy here:
f.Set(reflect.MakeFunc(f.Type(), makeDubboCallProxy(t.Name, funcOuts)))
log.Debug("set method [%s]", t.Name)
}
}

p.v = v

return nil
}

func (p *Proxy) Get() interface{} {
return p.v
}
19 changes: 3 additions & 16 deletions protocol/dubbo/dubbo_invoker.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import (
"errors"
"strconv"
"sync"
"time"
)

import (
@@ -49,27 +48,15 @@ func (di *DubboInvoker) Invoke(invocation protocol.Invocation) protocol.Result {
}
if async {
if callBack, ok := inv.CallBack().(func(response CallResponse)); ok {
result.Err = di.client.AsyncCall(url.Location, *url, inv.MethodName(), inv.Arguments(), callBack, inv.Reply(),
WithCallRequestTimeout(inv.Params()["requestTimeout"].(time.Duration)),
WithCallResponseTimeout(inv.Params()["responseTimeout"].(time.Duration)),
WithCallSerialID(inv.Params()["serialID"].(SerialID)),
WithCallMeta_All(inv.Params()["callMeta"].(map[interface{}]interface{})))
result.Err = di.client.AsyncCall(url.Location, *url, inv.MethodName(), inv.Arguments(), callBack, inv.Reply())
} else {
result.Err = di.client.CallOneway(url.Location, *url, inv.MethodName(), inv.Arguments(),
WithCallRequestTimeout(inv.Params()["requestTimeout"].(time.Duration)),
WithCallResponseTimeout(inv.Params()["responseTimeout"].(time.Duration)),
WithCallSerialID(inv.Params()["serialID"].(SerialID)),
WithCallMeta_All(inv.Params()["callMeta"].(map[interface{}]interface{})))
result.Err = di.client.CallOneway(url.Location, *url, inv.MethodName(), inv.Arguments())
}
} else {
if inv.Reply() == nil {
result.Err = Err_No_Reply
} else {
result.Err = di.client.Call(url.Location, *url, inv.MethodName(), inv.Arguments(), inv.Reply(),
WithCallRequestTimeout(inv.Params()["requestTimeout"].(time.Duration)),
WithCallResponseTimeout(inv.Params()["responseTimeout"].(time.Duration)),
WithCallSerialID(inv.Params()["serialID"].(SerialID)),
WithCallMeta_All(inv.Params()["callMeta"].(map[interface{}]interface{})))
result.Err = di.client.Call(url.Location, *url, inv.MethodName(), inv.Arguments(), inv.Reply())
result.Rest = inv.Reply() // reply should be set to result.Rest when sync
}
}
13 changes: 6 additions & 7 deletions protocol/invocation.go
Original file line number Diff line number Diff line change
@@ -26,12 +26,11 @@ type RPCInvocation struct {
callBack interface{}
attachments map[string]string
invoker Invoker
params map[string]interface{} // Store some parameters that are not easy to refine
}

// todo: arguments table is too many
func NewRPCInvocationForConsumer(methodName string, parameterTypes []reflect.Type, arguments []interface{},
reply interface{}, callBack interface{}, attachments map[string]string, invoker Invoker, params map[string]interface{}) *RPCInvocation {
reply interface{}, callBack interface{}, attachments map[string]string, invoker Invoker) *RPCInvocation {
return &RPCInvocation{
methodName: methodName,
parameterTypes: parameterTypes,
@@ -40,7 +39,6 @@ func NewRPCInvocationForConsumer(methodName string, parameterTypes []reflect.Typ
callBack: callBack,
attachments: attachments,
invoker: invoker,
params: params,
}
}

@@ -71,6 +69,9 @@ func (r *RPCInvocation) Attachments() map[string]string {
}

func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string {
if r.attachments == nil {
return defaultValue
}
value, ok := r.attachments[key]
if ok {
return value
@@ -81,14 +82,12 @@ func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string
func (r *RPCInvocation) Invoker() Invoker {
return r.invoker
}

// SetInvoker is called while getting url, maybe clusterInvoker?
func (r *RPCInvocation) SetInvoker() Invoker {
return r.invoker
}

func (r *RPCInvocation) Params() map[string]interface{} {
return r.params
}

func (r *RPCInvocation) CallBack() interface{} {
return r.callBack
}
4 changes: 2 additions & 2 deletions protocol/jsonrpc/http.go
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ import (
)

import (
"github.com/dubbo/dubbo-go/common/constant"
"github.com/dubbo/dubbo-go/config"
"github.com/dubbo/dubbo-go/public"
)

//////////////////////////////////////////////
@@ -104,7 +104,7 @@ func (c *HTTPClient) Call(ctx context.Context, service config.URL, req *Request,
reqTimeout = 1e8
}
httpHeader.Set("Timeout", reqTimeout.String())
if md, ok := ctx.Value(public.DUBBOGO_CTX_KEY).(map[string]string); ok {
if md, ok := ctx.Value(constant.DUBBOGO_CTX_KEY).(map[string]string); ok {
for k := range md {
httpHeader.Set(k, md[k])
}
4 changes: 2 additions & 2 deletions protocol/jsonrpc/jsonrpc_invoker.go
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@ import (
)

import (
"github.com/dubbo/dubbo-go/common/constant"
"github.com/dubbo/dubbo-go/config"
"github.com/dubbo/dubbo-go/protocol"
"github.com/dubbo/dubbo-go/public"
)

type JsonrpcInvoker struct {
@@ -37,7 +37,7 @@ func (ji *JsonrpcInvoker) Invoke(invocation protocol.Invocation) protocol.Result
url := inv.Invoker().GetUrl().(*config.URL)

req := ji.client.NewRequest(*url, inv.MethodName(), inv.Arguments())
ctx := context.WithValue(context.Background(), public.DUBBOGO_CTX_KEY, map[string]string{
ctx := context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{
"X-Proxy-Id": "dubbogo",
"X-Services": url.Service,
"X-Method": inv.MethodName(),
5 changes: 3 additions & 2 deletions protocol/jsonrpc/jsonrpc_protocol.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
import (
"github.com/dubbo/dubbo-go/common/extension"
"github.com/dubbo/dubbo-go/config"
"github.com/dubbo/dubbo-go/config/support"
"github.com/dubbo/dubbo-go/protocol"
)

@@ -45,8 +46,8 @@ func (jp *JsonrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter {

func (jp *JsonrpcProtocol) Refer(url config.IURL) protocol.Invoker {
invoker := NewJsonrpcInvoker(url, NewHTTPClient(&HTTPOptions{
HandshakeTimeout: config.GetConsumerConfig().ConnectTimeout,
HTTPTimeout: config.GetConsumerConfig().RequestTimeout,
HandshakeTimeout: support.GetConsumerConfig().ConnectTimeout,
HTTPTimeout: support.GetConsumerConfig().RequestTimeout,
}))
jp.SetInvokers(invoker)
log.Info("Refer service: ", url.(*config.URL).String())