Skip to content

Commit

Permalink
Merge pull request #1043 from xiaoliu10/replace_ci_icon
Browse files Browse the repository at this point in the history
Replace ci icon
  • Loading branch information
AlexStocks committed Feb 5, 2021
2 parents 7d0b63a + e396a96 commit 53302a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Apache Dubbo-go [中文](./README_CN.md) #

[![Build Status](https://travis-ci.org/apache/dubbo-go.svg?branch=master)](https://travis-ci.org/apache/dubbo-go)
[![Build Status](https://github.com/apache/dubbo-go/workflows/CI/badge.svg)](https://travis-ci.org/apache/dubbo-go)
[![codecov](https://codecov.io/gh/apache/dubbo-go/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-go)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/apache/dubbo-go?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/apache/dubbo-go)](https://goreportcard.com/report/github.com/apache/dubbo-go)
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Apache Dubbo-go [English](./README.md) #

[![Build Status](https://travis-ci.org/apache/dubbo-go.svg?branch=master)](https://travis-ci.org/apache/dubbo-go)
[![Build Status](https://github.com/apache/dubbo-go/workflows/CI/badge.svg)](https://travis-ci.org/apache/dubbo-go)
[![codecov](https://codecov.io/gh/apache/dubbo-go/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-go)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/apache/dubbo-go?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/apache/dubbo-go)](https://goreportcard.com/report/github.com/apache/dubbo-go)
Expand Down
22 changes: 12 additions & 10 deletions protocol/dubbo/dubbo_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
)

import (
"github.com/opentracing/opentracing-go"
perrors "github.com/pkg/errors"
uatomic "go.uber.org/atomic"
)

import (
Expand Down Expand Up @@ -62,7 +62,7 @@ type DubboInvoker struct {
// 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 constructor
Expand All @@ -73,12 +73,14 @@ func NewDubboInvoker(url *common.URL, client *remoting.ExchangeClient) *DubboInv
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.
Expand All @@ -87,15 +89,15 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati
err error
result protocol.RPCResult
)
if atomic.LoadInt64(&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
Expand Down Expand Up @@ -169,8 +171,8 @@ func (di *DubboInvoker) IsAvailable() bool {
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 {
Expand All @@ -179,7 +181,7 @@ func (di *DubboInvoker) Destroy() {
}
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)
}

Expand Down

0 comments on commit 53302a3

Please sign in to comment.