Skip to content

Commit

Permalink
Merge pull request apache#3 from apache/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sdttttt authored Sep 11, 2020
2 parents ad40c11 + d02f29d commit f9fb5ae
Show file tree
Hide file tree
Showing 212 changed files with 6,633 additions and 1,511 deletions.
28 changes: 28 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
# Release Notes
---

## 1.5.1

### New Features
- [Add dynamic tag router](https://github.com/apache/dubbo-go/pull/703)
- [Add TLS support](https://github.com/apache/dubbo-go/pull/685)
- [Add Nearest first for multiple registry](https://github.com/apache/dubbo-go/pull/659)
- [Add application and service level router](https://github.com/apache/dubbo-go/pull/662)
- [Add dynamic tag router](https://github.com/apache/dubbo-go/pull/665)

### Enhancement
- [Avoid init the log twice](https://github.com/apache/dubbo-go/pull/719)
- [Correct words and format codes](https://github.com/apache/dubbo-go/pull/704)
- [Change log stack level from warn to error](https://github.com/apache/dubbo-go/pull/702)
- [Optimize remotes configuration](https://github.com/apache/dubbo-go/pull/687)

### Bugfixes
- [Fix register service instance after provider config load](https://github.com/apache/dubbo-go/pull/694)
- [Fix call subscribe function asynchronously](https://github.com/apache/dubbo-go/pull/721)
- [Fix tag router rule copy](https://github.com/apache/dubbo-go/pull/721)
- [Fix nacos unit test failed](https://github.com/apache/dubbo-go/pull/705)
- [Fix can not inovke nacos destroy when graceful shutdown](https://github.com/apache/dubbo-go/pull/689)
- [Fix zk lost event](https://github.com/apache/dubbo-go/pull/692)
- [Fix k8s ut bug](https://github.com/apache/dubbo-go/pull/693)

Milestone: [https://github.com/apache/dubbo-go/milestone/2?closed=1](https://github.com/apache/dubbo-go/milestone/2?closed=1)

Project: [https://github.com/apache/dubbo-go/projects/8](https://github.com/apache/dubbo-go/projects/8)

## 1.5.0

### New Features
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache Dubbo Go
Apache Dubbo-go
Copyright 2018-2020 The Apache Software Foundation

This product includes software developed at
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Apache License, Version 2.0

## Release note ##

[v1.5.1 - Aug 23, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.5.1)

[v1.5.0 - July 24, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.5.0)

[v1.4.0 - Mar 17, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0)
Expand All @@ -34,7 +36,7 @@ Both extension module and layered project architecture is according to Apache Du

![dubbo go extend](./doc/pic/arch/dubbo-go-ext.png)

If you wanna know more about dubbo-go, please visit this reference [Project Architeture design](https://github.com/apache/dubbo-go/wiki/dubbo-go-V1.0-design)
If you wanna know more about dubbo-go, please visit this reference [Project Architecture design](https://github.com/apache/dubbo-go/wiki/dubbo-go-V1.0-design)

## Feature list ##

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ go test ./... -coverprofile=coverage.txt -covermode=atomic

## [User List](https://github.com/apache/dubbo-go/issues/2)

若你正在使用 [apache/dubbo-go](github.com/apache/dubbo-go) 且认为其有用或者向对其做改进,请忝列贵司信息于 [用户列表](https://github.com/apache/dubbo-go/issues/2)以便我们知晓之
若你正在使用 [apache/dubbo-go](github.com/apache/dubbo-go) 且认为其有用或者想对其做改进,请添列贵司信息于 [用户列表](https://github.com/apache/dubbo-go/issues/2)以便我们知晓

<div>
<table>
Expand Down
3 changes: 3 additions & 0 deletions before_ut.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ xcopy /f "%zkJar%" "cluster/router/chain/zookeeper-4unittest/contrib/fatjar/"
md cluster\router\condition\zookeeper-4unittest\contrib\fatjar
xcopy /f "%zkJar%" "cluster/router/condition/zookeeper-4unittest/contrib/fatjar/"

mkdir -p cluster/router/tag/zookeeper-4unittest/contrib/fatjar
cp ${zkJar} cluster/router/tag/zookeeper-4unittest/contrib/fatjar

md metadata\report\zookeeper\zookeeper-4unittest\contrib\fatjar
xcopy /f "%zkJar%" "metadata/report/zookeeper/zookeeper-4unittest/contrib/fatjar/"
3 changes: 3 additions & 0 deletions before_ut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ cp ${zkJar} cluster/router/chain/zookeeper-4unittest/contrib/fatjar
mkdir -p cluster/router/condition/zookeeper-4unittest/contrib/fatjar
cp ${zkJar} cluster/router/condition/zookeeper-4unittest/contrib/fatjar

mkdir -p cluster/router/tag/zookeeper-4unittest/contrib/fatjar
cp ${zkJar} cluster/router/tag/zookeeper-4unittest/contrib/fatjar

mkdir -p metadata/report/zookeeper/zookeeper-4unittest/contrib/fatjar
cp ${zkJar} metadata/report/zookeeper/zookeeper-4unittest/contrib/fatjar
1 change: 1 addition & 0 deletions cluster/cluster_impl/available_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func NewAvailableCluster() cluster.Cluster {
return &availableCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluser *availableCluster) Join(directory cluster.Directory) protocol.Invoker {
return NewAvailableClusterInvoker(directory)
}
19 changes: 19 additions & 0 deletions cluster/cluster_impl/base_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package cluster_impl

import (
"context"
)

import (
gxnet "github.com/dubbogo/gost/net"
perrors "github.com/pkg/errors"
Expand All @@ -36,6 +40,7 @@ type baseClusterInvoker struct {
availablecheck bool
destroyed *atomic.Bool
stickyInvoker protocol.Invoker
interceptor cluster.ClusterInterceptor
}

func newBaseClusterInvoker(directory cluster.Directory) baseClusterInvoker {
Expand Down Expand Up @@ -146,6 +151,20 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc
return selectedInvoker
}

func (invoker *baseClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
if invoker.interceptor != nil {
invoker.interceptor.BeforeInvoker(ctx, invocation)

result := invoker.interceptor.DoInvoke(ctx, invocation)

invoker.interceptor.AfterInvoker(ctx, invocation)

return result
}

return nil
}

func isInvoked(selectedInvoker protocol.Invoker, invoked []protocol.Invoker) bool {
for _, i := range invoked {
if i == selectedInvoker {
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/broadcast_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewBroadcastCluster() cluster.Cluster {
return &broadcastCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluster *broadcastCluster) Join(directory cluster.Directory) protocol.Invoker {
return newBroadcastClusterInvoker(directory)
}
1 change: 1 addition & 0 deletions cluster/cluster_impl/broadcast_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func newBroadcastClusterInvoker(directory cluster.Directory) protocol.Invoker {
}
}

// nolint
func (invoker *broadcastClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
invokers := invoker.directory.List(invocation)
err := invoker.checkInvokers(invokers, invocation)
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/failback_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewFailbackCluster() cluster.Cluster {
return &failbackCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluster *failbackCluster) Join(directory cluster.Directory) protocol.Invoker {
return newFailbackClusterInvoker(directory)
}
1 change: 1 addition & 0 deletions cluster/cluster_impl/failback_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (invoker *failbackClusterInvoker) checkRetry(retryTask *retryTimerTask, err
}
}

// nolint
func (invoker *failbackClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
invokers := invoker.directory.List(invocation)
if err := invoker.checkInvokers(invokers, invocation); err != nil {
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/failfast_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewFailFastCluster() cluster.Cluster {
return &failfastCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluster *failfastCluster) Join(directory cluster.Directory) protocol.Invoker {
return newFailFastClusterInvoker(directory)
}
1 change: 1 addition & 0 deletions cluster/cluster_impl/failfast_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func newFailFastClusterInvoker(directory cluster.Directory) protocol.Invoker {
}
}

// nolint
func (invoker *failfastClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
invokers := invoker.directory.List(invocation)
err := invoker.checkInvokers(invokers, invocation)
Expand Down
6 changes: 3 additions & 3 deletions cluster/cluster_impl/failover_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ package cluster_impl

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

type failoverCluster struct{}

const name = "failover"

func init() {
extension.SetCluster(name, NewFailoverCluster)
extension.SetCluster(constant.FAILOVER_CLUSTER_NAME, NewFailoverCluster)
}

// NewFailoverCluster returns a failover cluster instance
Expand All @@ -40,6 +39,7 @@ func NewFailoverCluster() cluster.Cluster {
return &failoverCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluster *failoverCluster) Join(directory cluster.Directory) protocol.Invoker {
return newFailoverClusterInvoker(directory)
}
8 changes: 6 additions & 2 deletions cluster/cluster_impl/failover_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cluster_impl

import (
"context"
"fmt"
"strconv"
)

Expand All @@ -44,6 +45,7 @@ func newFailoverClusterInvoker(directory cluster.Directory) protocol.Invoker {
}
}

// nolint
func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
var (
result protocol.Result
Expand Down Expand Up @@ -91,8 +93,10 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
invokerSvc := invoker.GetUrl().Service()
invokerUrl := invoker.directory.GetUrl()
return &protocol.RPCResult{
Err: perrors.Errorf("Failed to invoke the method %v in the service %v. Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. Last error is %v.",
methodName, invokerSvc, retries, providers, len(providers), len(invokers), invokerUrl, ip, constant.Version, result.Error().Error(),
Err: perrors.Wrap(result.Error(), fmt.Sprintf("Failed to invoke the method %v in the service %v. "+
"Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. "+
"Last error is %+v.", methodName, invokerSvc, retries, providers, len(providers), len(invokers),
invokerUrl, ip, constant.Version, result.Error().Error()),
)}
}

Expand Down
15 changes: 15 additions & 0 deletions cluster/cluster_impl/failover_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
// mock invoker
// ///////////////////////////

// nolint
type MockInvoker struct {
url common.URL
available bool
Expand All @@ -51,6 +52,7 @@ type MockInvoker struct {
successCount int
}

// nolint
func NewMockInvoker(url common.URL, successCount int) *MockInvoker {
return &MockInvoker{
url: url,
Expand All @@ -60,23 +62,28 @@ func NewMockInvoker(url common.URL, successCount int) *MockInvoker {
}
}

// nolint
func (bi *MockInvoker) GetUrl() common.URL {
return bi.url
}

// nolint
func (bi *MockInvoker) IsAvailable() bool {
return bi.available
}

// nolint
func (bi *MockInvoker) IsDestroyed() bool {
return bi.destroyed
}

// nolint
type rest struct {
tried int
success bool
}

// nolint
func (bi *MockInvoker) Invoke(c context.Context, invocation protocol.Invocation) protocol.Result {
count++
var (
Expand All @@ -93,14 +100,17 @@ func (bi *MockInvoker) Invoke(c context.Context, invocation protocol.Invocation)
return result
}

// nolint
func (bi *MockInvoker) Destroy() {
logger.Infof("Destroy invoker: %v", bi.GetUrl().String())
bi.destroyed = true
bi.available = false
}

// nolint
var count int

// nolint
func normalInvoke(successCount int, urlParam url.Values, invocations ...*invocation.RPCInvocation) protocol.Result {
extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance)
failoverCluster := NewFailoverCluster()
Expand All @@ -119,20 +129,23 @@ func normalInvoke(successCount int, urlParam url.Values, invocations ...*invocat
return clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{})
}

// nolint
func TestFailoverInvokeSuccess(t *testing.T) {
urlParams := url.Values{}
result := normalInvoke(3, urlParams)
assert.NoError(t, result.Error())
count = 0
}

// nolint
func TestFailoverInvokeFail(t *testing.T) {
urlParams := url.Values{}
result := normalInvoke(4, urlParams)
assert.Errorf(t, result.Error(), "error")
count = 0
}

// nolint
func TestFailoverInvoke1(t *testing.T) {
urlParams := url.Values{}
urlParams.Set(constant.RETRIES_KEY, "3")
Expand All @@ -141,6 +154,7 @@ func TestFailoverInvoke1(t *testing.T) {
count = 0
}

// nolint
func TestFailoverInvoke2(t *testing.T) {
urlParams := url.Values{}
urlParams.Set(constant.RETRIES_KEY, "2")
Expand All @@ -152,6 +166,7 @@ func TestFailoverInvoke2(t *testing.T) {
count = 0
}

// nolint
func TestFailoverDestroy(t *testing.T) {
extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance)
failoverCluster := NewFailoverCluster()
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/failsafe_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewFailsafeCluster() cluster.Cluster {
return &failsafeCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluster *failsafeCluster) Join(directory cluster.Directory) protocol.Invoker {
return newFailsafeClusterInvoker(directory)
}
1 change: 1 addition & 0 deletions cluster/cluster_impl/failsafe_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func newFailsafeClusterInvoker(directory cluster.Directory) protocol.Invoker {
}
}

// nolint
func (invoker *failsafeClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
invokers := invoker.directory.List(invocation)

Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/forking_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewForkingCluster() cluster.Cluster {
return &forkingCluster{}
}

// Join returns a baseClusterInvoker instance
func (cluster *forkingCluster) Join(directory cluster.Directory) protocol.Invoker {
return newForkingClusterInvoker(directory)
}
2 changes: 1 addition & 1 deletion cluster/cluster_impl/forking_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func newForkingClusterInvoker(directory cluster.Directory) protocol.Invoker {
}
}

// Invoke ...
// nolint
func (invoker *forkingClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
if err := invoker.checkWhetherDestroyed(); err != nil {
return &protocol.RPCResult{Err: err}
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/mock_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewMockCluster() cluster.Cluster {
return &mockCluster{}
}

// nolint
func (cluster *mockCluster) Join(directory cluster.Directory) protocol.Invoker {
return protocol.NewBaseInvoker(directory.GetUrl())
}
Loading

0 comments on commit f9fb5ae

Please sign in to comment.