You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/02/05 15:38:19 UTC
[dubbo-go] branch feature/dubbo_invoker_reqnum updated (9c3bd0e ->
53302a3)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a change to branch feature/dubbo_invoker_reqnum
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git.
omit 9c3bd0e Merge pull request #1043 from xiaoliu10/replace_ci_icon
new 53302a3 Merge pull request #1043 from xiaoliu10/replace_ci_icon
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (9c3bd0e)
\
N -- N -- N refs/heads/feature/dubbo_invoker_reqnum (53302a3)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
protocol/dubbo/dubbo_invoker.go | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
[dubbo-go] 01/01: Merge pull request #1043 from
xiaoliu10/replace_ci_icon
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch feature/dubbo_invoker_reqnum
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit 53302a318d95b7070e9c97c8b7981911bb902b82
Merge: 7d0b63a e396a96
Author: Xin.Zh <dr...@foxmail.com>
AuthorDate: Thu Feb 4 20:10:13 2021 +0800
Merge pull request #1043 from xiaoliu10/replace_ci_icon
Replace ci icon
README.md | 2 +-
README_CN.md | 2 +-
protocol/dubbo/dubbo_invoker.go | 22 ++++++++++++----------
3 files changed, 14 insertions(+), 12 deletions(-)
diff --cc protocol/dubbo/dubbo_invoker.go
index 8134a90,59202d5..7f2f8ad
--- a/protocol/dubbo/dubbo_invoker.go
+++ b/protocol/dubbo/dubbo_invoker.go
@@@ -20,15 -20,14 +20,15 @@@ package dubb
import (
"context"
"strconv"
+ "strings"
"sync"
-- "sync/atomic"
"time"
)
import (
"github.com/opentracing/opentracing-go"
perrors "github.com/pkg/errors"
++ uatomic "go.uber.org/atomic"
)
import (
@@@ -49,36 -46,25 +49,38 @@@ var
)
var (
- attachmentKey = []string{constant.INTERFACE_KEY, constant.GROUP_KEY, constant.TOKEN_KEY, constant.TIMEOUT_KEY}
+ attachmentKey = []string{constant.INTERFACE_KEY, constant.GROUP_KEY, constant.TOKEN_KEY, constant.TIMEOUT_KEY,
+ constant.VERSION_KEY}
)
-// DubboInvoker is dubbo client invoker.
+// DubboInvoker is implement of protocol.Invoker. A dubboInvoker refer to one service and ip.
type DubboInvoker struct {
protocol.BaseInvoker
- client *Client
+ // the exchange layer, it is focus on network communication.
+ client *remoting.ExchangeClient
quitOnce sync.Once
+ // timeout for service(interface) level.
+ timeout time.Duration
// Used to record the number of requests. -1 represent this DubboInvoker is destroyed
-- reqNum int64
++ reqNum uatomic.Int64
}
-// NewDubboInvoker create dubbo client invoker.
-func NewDubboInvoker(url common.URL, client *Client) *DubboInvoker {
- return &DubboInvoker{
+// NewDubboInvoker constructor
+func NewDubboInvoker(url *common.URL, client *remoting.ExchangeClient) *DubboInvoker {
+ requestTimeout := config.GetConsumerConfig().RequestTimeout
+
+ requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout)
+ if t, err := time.ParseDuration(requestTimeoutStr); err == nil {
+ requestTimeout = t
+ }
- return &DubboInvoker{
++ di := &DubboInvoker{
BaseInvoker: *protocol.NewBaseInvoker(url),
client: client,
-- reqNum: 0,
+ timeout: requestTimeout,
}
++ di.reqNum.Store(0)
++
++ return di
}
// Invoke call remoting.
@@@ -87,19 -73,17 +89,19 @@@ func (di *DubboInvoker) Invoke(ctx cont
err error
result protocol.RPCResult
)
- if atomic.LoadInt64(&di.reqNum) < 0 {
- if di.reqNum < 0 {
++ if di.reqNum.Load() < 0 {
// Generally, the case will not happen, because the invoker has been removed
// from the invoker list before destroy,so no new request will enter the destroyed invoker
logger.Warnf("this dubboInvoker is destroyed")
result.Err = ErrDestroyedInvoker
return &result
}
-- atomic.AddInt64(&(di.reqNum), 1)
-- defer atomic.AddInt64(&(di.reqNum), -1)
++ di.reqNum.Add(1)
++ defer di.reqNum.Add(-1)
inv := invocation.(*invocation_impl.RPCInvocation)
+ // init param
+ inv.SetAttachments(constant.PATH_KEY, di.GetUrl().GetParam(constant.INTERFACE_KEY, ""))
for _, k := range attachmentKey {
if v := di.GetUrl().GetParam(k, ""); len(v) > 0 {
inv.SetAttachments(k, v)
@@@ -169,8 -127,8 +171,8 @@@ func (di *DubboInvoker) IsAvailable() b
func (di *DubboInvoker) Destroy() {
di.quitOnce.Do(func() {
for {
-- if di.reqNum == 0 {
-- di.reqNum = -1
++ if di.reqNum.Load() == 0 {
++ di.reqNum.Store(-1)
logger.Infof("dubboInvoker is destroyed,url:{%s}", di.GetUrl().Key())
di.BaseInvoker.Destroy()
if di.client != nil {
@@@ -179,7 -137,7 +181,7 @@@
}
break
}
-- logger.Warnf("DubboInvoker is to be destroyed, wait {%v} req end,url:{%s}", di.reqNum, di.GetUrl().Key())
++ logger.Warnf("DubboInvoker is to be destroyed, wait {%v} req end,url:{%s}", di.reqNum.Load(), di.GetUrl().Key())
time.Sleep(1 * time.Second)
}