Skip to content

Commit

Permalink
Merge 3.0 to master (#1606)
Browse files Browse the repository at this point in the history
* build(deps): bump github.com/hashicorp/vault/sdk from 0.2.1 to 0.3.0 (#1552)

Bumps [github.com/hashicorp/vault/sdk](https://github.com/hashicorp/vault) from 0.2.1 to 0.3.0.
- [Release notes](https://github.com/hashicorp/vault/releases)
- [Changelog](https://github.com/hashicorp/vault/blob/main/CHANGELOG.md)
- [Commits](hashicorp/vault@sdk/v0.2.1...v0.3.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/vault/sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* delete useless codes (#1551)

* Update CHANGELOG.md

* [#1559]: adjust the startup process of the configuration center (#1560)

* [#1559]:
1. fix the startup process of the configuration center(remove error log)
2. refactor zk registry listener

* delete redundant dynamic configuration center cache

Co-authored-by: dongjianhui03 <dongjianhui03@meituan.com>

* [#1276]modify the name of the receiver to a single character (#1561)

Co-authored-by: dongjianhui03 <dongjianhui03@meituan.com>

* style(common): rename constants in camel-case style (#1563)

* style(common): rename constants in camel-case style

* style(common): rename Ttl to TTL

* fix: #1558: Set root config to global ptr in Init() function. (#1564)

* fix: #1558

* fix: change the api to start the app by config-api

* fix: in the Consumer service, the Reference config property ‘check’ use the Consumer config when omitted

* Triple upgrade to grpc (#1566)

* fix: init triple grpc

* fix: delete replace

* Fix: upgrade triple grpc

* Fix: remove unused file

* Fix decrease grpc go version to 1.14

* Fix: add server side serialization

* register not use metadata configuration.

* build(deps): bump github.com/go-resty/resty/v2 from 2.3.0 to 2.7.0 (#1579)

Bumps [github.com/go-resty/resty/v2](https://github.com/go-resty/resty) from 2.3.0 to 2.7.0.
- [Release notes](https://github.com/go-resty/resty/releases)
- [Commits](go-resty/resty@v2.3.0...v2.7.0)

---
updated-dependencies:
- dependency-name: github.com/go-resty/resty/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump google.golang.org/grpc from 1.41.0 to 1.42.0 (#1578)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.42.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.41.0...v1.42.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump github.com/knadh/koanf from 1.3.0 to 1.3.2 (#1577)

Bumps [github.com/knadh/koanf](https://github.com/knadh/koanf) from 1.3.0 to 1.3.2.
- [Release notes](https://github.com/knadh/koanf/releases)
- [Commits](knadh/koanf@v1.3.0...v1.3.2)

---
updated-dependencies:
- dependency-name: github.com/knadh/koanf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: registry param

* fix: fix ns and group

* fix: integrate test

* Fix: integrate test

* fix: url fmt

* fix: nacos servicediscovery group

* Fix: enhance zk

* start application (#1571)

Co-authored-by: wangxiaowei14227 <wangxiaowei14227@autohome.com.cn>
Co-authored-by: lizhixin.lzx <lizhixin.lzx@alibaba-inc.com>
Co-authored-by: LaurenceLiZhixin <382673304@qq.com>

* graceful shutdwon filter (#1585)

Co-authored-by: wangxiaowei14227 <wangxiaowei14227@autohome.com.cn>

* Fix: some bugs and features for 3.0 (#1586)

* fix: some bugs

* Fix: remove file\k8s registry, k8s remote

* refactor listenDirEvent
1. remove CLEAR label;
2. remove register/unregister logic for watch children;
3. reorder the zk dynamic configuration code
4. adapt the gost

* hessian encode attachments return error (#1588)

* upgrade gost dependency version

* upgrade hessian to v1.9.5 (#1595)

* build(deps): bump k8s.io/apimachinery from 0.16.9 to 0.22.4 (#1600)

Bumps [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) from 0.16.9 to 0.22.4.
- [Release notes](https://github.com/kubernetes/apimachinery/releases)
- [Commits](kubernetes/apimachinery@v0.16.9...v0.22.4)

---
updated-dependencies:
- dependency-name: k8s.io/apimachinery
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ftr: triple tracing (#1596)

* ftr: triple tracing

* fix: if-else to switch

* [fix #1590] filter single instance (#1591)

* filter single instance

* filter single instance

Co-authored-by: wangxiaowei14227 <wangxiaowei14227@autohome.com.cn>

* Ftr/triple reflect support (#1603)

* ftr: triple-reflection

* fix: comment and var name

* Fix: comment typo

* Fix: official website

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xin.Zh <dragoncharlie@foxmail.com>
Co-authored-by: Mulavar <978007503@qq.com>
Co-authored-by: dongjianhui03 <dongjianhui03@meituan.com>
Co-authored-by: Xuewei Niu <a@nxw.name>
Co-authored-by: PhilYue <phil.yue@foxmail.com>
Co-authored-by: lizhixin.lzx <lizhixin.lzx@alibaba-inc.com>
Co-authored-by: sanxun0325 <bbz17640380550@163.com>
Co-authored-by: Xuewei Niu <justxuewei@apache.org>
Co-authored-by: zhaoyunxing <zhaoyunxing@apache.org>
Co-authored-by: wangxw <2484713618@qq.com>
Co-authored-by: wangxiaowei14227 <wangxiaowei14227@autohome.com.cn>
Co-authored-by: 望哥 <gelnyang@163.com>
  • Loading branch information
14 people committed Nov 22, 2021
1 parent cc7af11 commit 5cd1a52
Show file tree
Hide file tree
Showing 235 changed files with 4,217 additions and 5,304 deletions.
147 changes: 146 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,152 @@
# Release Notes
---

## 3.0.0
## 3.0.0-rc3

### Feature:

- Triple features

- [New triple pb generation tool](https://github.com/dubbogo/tools/pull/17)

Refer to [QuickStart of dubbo-go 3.0](https://dubbogo.github.io/zh-cn/docs/user/quickstart/3.0/quickstart.html), and [Dubbo-go-samples](https://github.com/apache/dubbo-go-samples) to try protoc-gen-go-triple pb generator plugin.

- [Response exception from client](https://github.com/dubbogo/triple/pull/30)

Triple client can get the error stacks from server, pointing to real error occurs position.

- [Multi params support](https://github.com/apache/dubbo-go/pull/1344)

- [New metrics support](https://github.com/apache/dubbo-go/pull/1540)

Refer to [Docs of dubbo-go 3.0 Metrics](https://dubbogo.github.io/zh-cn/docs/user/samples/metrics.html), and [dubbo-go-samples/metrics](https://github.com/apache/dubbo-go-samples/tree/master/metrics)] to try new metrics support.

- [Remove sleep to wait for service discovery logic](https://github.com/apache/dubbo-go/pull/1531)

Set reference check default to true and remove extra time.Sleep logic in client side during service-discovery [remove time.Sleep](https://github.com/apache/dubbo-go-samples/pull/276/files)

- [Registry Waittime configurable](https://github.com/apache/dubbo-go/pull/1516/files)

- [Dynamic Route Config](https://github.com/apache/dubbo-go/pull/1519)

Refer to [Docs of dubbo-go 3.0 Router](https://dubbogo.github.io/zh-cn/docs/user/samples/mesh_router.html), and [dubbo-go-samples/meshrouter](https://github.com/apache/dubbo-go-samples/tree/master/route/meshroute) to try dynamic mesh router support.

- [New config API support](https://github.com/apache/dubbo-go/pull/1499) [New root config API builder](https://github.com/apache/dubbo-go/pull/1491)

Refer to [Docs of dubbo-go 3.0 Configuration](https://dubbogo.github.io/zh-cn/docs/user/concept/configuration.html), and [dubbo-go-samples/config-api](https://github.com/apache/dubbo-go-samples/tree/master/config-api) to try new config API.

- [Support custom registry group name on Nacos](https://github.com/apache/dubbo-go/pull/1353)

- [GRPC supports multi pb](https://github.com/apache/dubbo-go/pull/1361)

- [New logger support](https://github.com/apache/dubbo-go/pull/1335)

Refer to [Docs of dubbo-go 3.0 logger](https://dubbogo.github.io/zh-cn/docs/user/samples/custom-logger.html), and [dubbo-go-samples/logger](https://github.com/apache/dubbo-go-samples/tree/master/logger) to try new logger support.

- [Generic invocation supports](https://github.com/apache/dubbo-go/pull/1315)

Refer to [Docs of dubbo-go 3.0 generic](https://dubbogo.github.io/zh-cn/docs/user/samples/generic.html), and [dubbo-go-samples/generic](https://github.com/apache/dubbo-go-samples/tree/master/generic) to try new generic support.

- [Support key generate function in service event](https://github.com/apache/dubbo-go/pull/1286)



### Enhancement:

- [Configuration Enhancement](https://github.com/apache/dubbo-go/commit/1397e8bba97f14b7656a5afc9bc92530bb693092)

One of the biggest update in this release is the configuration optimization. We discarded the old configuration and introduced a new one. Currently, the new configuration has been updated to [the master branch of samples](https://github.com/apache/dubbo-go-samples) (corresponding to latest dubbo-go 3.0), and there are introductions and detailed examples on the our website [dubbogo.github](https://dubbogo.github.io).

- Triple:

- [Triple CPU usage optimization](https://github.com/dubbogo/triple/pull/32/files)

Set default tcp read buffer to 4k to decrease gc, and descrease CPU usage by 60% of 3.0.0-rc2

- [Add Triple Debug Log](https://github.com/dubbogo/triple/pull/29)

- [Support Apollo secret](https://github.com/apache/dubbo-go/pull/1533)

- [Use class Name as the default reference name ](https://github.com/apache/dubbo-go/pull/1339)

You can set service/refernce key to provider/consumer's struct name: [Config samples](https://github.com/apache/dubbo-go-samples/blob/master/helloworld/go-server/conf/dubbogo.yml#L15) & [Target provider struct](https://github.com/apache/dubbo-go-samples/blob/master/helloworld/go-server/cmd/server.go#L45),

And there is no needs to define (p*Provider) Reference() method from now on.

- [Set default logger level to info](https://github.com/apache/dubbo-go/pull/1549/files#diff-d5ab135265094924568957f56eaef061c7948d2664daa995fbe0de4c7ab2d272R82)
- [Refactor of filter package sturcture](https://github.com/apache/dubbo-go/pull/1299)
- [Refactor of cluster package structure](https://github.com/apache/dubbo-go/pull/1507)



### Bugfix:

- [Heartbeat's timeout will modify consumer's timeout](https://github.com/apache/dubbo-go/pull/1532)

- [Remove zk test to ensure ut could be run locally](https://github.com/apache/dubbo-go/pull/1357)

- [Add Application Registry](https://github.com/apache/dubbo-go/pull/1493)

- [Change serviceName like java style on nacos](https://github.com/apache/dubbo-go/pull/1352)

- [Url serialization bug](https://github.com/apache/dubbo-go/pull/1292)

- [Change the key of a mock echo filter](https://github.com/apache/dubbo-go/pull/1381)

- [Fix: fix the exception when tcp timeout is less than 1s for 3.0 #1362](https://github.com/apache/dubbo-go/pull/1380)

- [Registry timeout not pars](https://github.com/apache/dubbo-go/pull/1392)

- [Fix Isprovider check](https://github.com/apache/dubbo-go/pull/1500)

- [Delete zk registry when set defualt consumer/provider config](https://github.com/apache/dubbo-go/pull/1324/files)


## 3.0.0-rc2

### New Features

- [Add Triple Msgpack Codec](https://github.com/apache/dubbo-go/pull/1242)
- [Add Triple user defined serializer support](https://github.com/apache/dubbo-go/pull/1242)
- [Add gRPC provider reference in codes generated by protoc-gen-dubbo3](https://github.com/apache/dubbo-go/pull/1240)
- [Add integration tests using dubbo-go-samples](https://github.com/apache/dubbo-go/pull/1223)
- [Add service discovery support etcd remote reporter](https://github.com/apache/dubbo-go/pull/1221)
- [Add service discovery support nacos remote reporter](https://github.com/apache/dubbo-go/pull/1218)
- [Add grpc server reflection register logic](https://github.com/apache/dubbo-go/pull/1216)

### Enhancement

- [Make remote metadata center configurable](https://github.com/apache/dubbo-go/pull/1258)
- [Enhance nacos connection](https://github.com/apache/dubbo-go/pull/1255)
- [Add unit tests for zk metadata report](https://github.com/apache/dubbo-go/pull/1229)
- [Restructuring remoting metadata service](https://github.com/apache/dubbo-go/pull/1227)
- [Dependency prompting for unit tests](https://github.com/apache/dubbo-go/pull/1212)
- [Make cluster interceptor a chain](https://github.com/apache/dubbo-go/pull/1211)
- [Improve etcd version and change create to put](https://github.com/apache/dubbo-go/pull/1203)
- [Remove reflect in grpc server](https://github.com/apache/dubbo-go/pull/1200)
- [Change lb hash logic](https://github.com/apache/dubbo-go/pull/1267)

### Bugfixes

- [Fix: zk invoker refer check fail,and service will be added in cache invokers fail problem](https://github.com/apache/dubbo-go/pull/1249)
- [Fix: app level service discovery local mod URL serialize fail problem](https://github.com/apache/dubbo-go/pull/1238)
- [Fix: m1 cpu exec fail problem](https://github.com/apache/dubbo-go/pull/1236)
- [Fix: metadata info struct contains unsupported field](https://github.com/apache/dubbo-go/pull/1234)
- [Fix: go race in directory](https://github.com/apache/dubbo-go/pull/1222)
- [Fix: zk name changes from default to conn location](https://github.com/apache/dubbo-go/pull/1263)

### Dependencies

- [bump actions/cache from 2.1.5 to 2.1.6](https://github.com/apache/dubbo-go/pull/1230)

Milestone:

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




## 3.0.0-rc1

### New Features
- [Add triple protocol](https://github.com/apache/dubbo-go/pull/1071)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[中文 🇨🇳](./README_CN.md)

Apache Dubbo-go, a Dubbo implementation written in Golang, is born to bridge the gap between Java and Golang. Please visit our [official website](https://dubbogo.github.io) for the quick start and documentation.
Apache Dubbo-go, a Dubbo implementation written in Golang, is born to bridge the gap between Java and Golang. Please visit our [official website](https://dubbo.apache.org/zh/docs/languages/golang/) for the quick start and documentation.

## Architecture

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[English 🇺🇸](./README.md)

Apache Dubbo Go 语言实现,架起 Java 和 Golang 之间的桥梁,与 gRPC/Spring Cloud 生态互联互通,带领 Java 生态享受云原生时代的技术红利。请访问我们的[官方网站](https://dubbogo.github.io)查看快速开始和文档。
Apache Dubbo Go 语言实现,架起 Java 和 Golang 之间的桥梁,与 gRPC/Spring Cloud 生态互联互通,带领 Java 生态享受云原生时代的技术红利。请访问我们的[官方网站](https://dubbo.apache.org/zh/docs/languages/golang/)查看快速开始和文档。

## 架构

Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster/available/cluster_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
)

var availableUrl, _ = common.NewURL(fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider",
constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
constant.LocalHostValue, constant.DefaultPort))

func registerAvailable(invoker *mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance("random", random.NewLoadBalance)
Expand Down
14 changes: 6 additions & 8 deletions cluster/cluster/base/cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func (invoker *ClusterInvoker) DoSelect(lb loadbalance.LoadBalance, invocation p
}

url := invokers[0].GetURL()
sticky := url.GetParamBool(constant.STICKY_KEY, false)
sticky := url.GetParamBool(constant.StickyKey, false)
// Get the service method sticky config if have
sticky = url.GetMethodParamBool(invocation.MethodName(), constant.STICKY_KEY, sticky)
sticky = url.GetMethodParamBool(invocation.MethodName(), constant.StickyKey, sticky)

if invoker.StickyInvoker != nil && !isInvoked(invoker.StickyInvoker, invokers) {
invoker.StickyInvoker = nil
Expand Down Expand Up @@ -155,11 +155,9 @@ func (invoker *ClusterInvoker) doSelectInvoker(lb loadbalance.LoadBalance, invoc
}
return reselectedInvoker
}
} else {
return selectedInvoker
}
logger.Errorf("all %d invokers is unavailable for %s.", len(invokers), selectedInvoker.GetURL().String())
return nil

return selectedInvoker
}

func isInvoked(selectedInvoker protocol.Invoker, invoked []protocol.Invoker) bool {
Expand All @@ -176,10 +174,10 @@ func GetLoadBalance(invoker protocol.Invoker, invocation protocol.Invocation) lo

methodName := invocation.MethodName()
// Get the service loadbalance config
lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE)
lb := url.GetParam(constant.LoadbalanceKey, constant.DefaultLoadbalance)

// Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); len(v) > 0 {
if v := url.GetMethodParam(methodName, constant.LoadbalanceKey, ""); len(v) > 0 {
lb = v
}
return extension.GetLoadbalance(lb)
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster/broadcast/cluster_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
)

var broadcastUrl, _ = common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))

func registerBroadcast(mockInvokers ...*mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance("random", random.NewLoadBalance)
Expand Down
12 changes: 6 additions & 6 deletions cluster/cluster/failback/cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ func newClusterInvoker(directory directory.Directory) protocol.Invoker {
invoker := &clusterInvoker{
ClusterInvoker: base.NewClusterInvoker(directory),
}
retriesConfig := invoker.GetURL().GetParam(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES)
retriesConfig := invoker.GetURL().GetParam(constant.RetriesKey, constant.DefaultFailbackTimes)
retries, err := strconv.Atoi(retriesConfig)
if err != nil || retries < 0 {
logger.Error("Your retries config is invalid,pls do a check. And will use the default fail back times configuration instead.")
retries = constant.DEFAULT_FAILBACK_TIMES_INT
retries = constant.DefaultFailbackTimesInt
}

failbackTasksConfig := invoker.GetURL().GetParamInt(constant.FAIL_BACK_TASKS_KEY, constant.DEFAULT_FAILBACK_TASKS)
failbackTasksConfig := invoker.GetURL().GetParamInt(constant.FailBackTasksKey, constant.DefaultFailbackTasks)
if failbackTasksConfig <= 0 {
failbackTasksConfig = constant.DEFAULT_FAILBACK_TASKS
failbackTasksConfig = constant.DefaultFailbackTasks
}
invoker.maxRetries = int64(retries)
invoker.failbackTasks = failbackTasksConfig
Expand Down Expand Up @@ -141,10 +141,10 @@ func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.I

// Get the service loadbalance config
url := invokers[0].GetURL()
lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE)
lb := url.GetParam(constant.LoadbalanceKey, constant.DefaultLoadbalance)
// Get the service method loadbalance config if have
methodName := invocation.MethodName()
if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" {
if v := url.GetMethodParam(methodName, constant.LoadbalanceKey, ""); v != "" {
lb = v
}

Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster/failback/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
)

var failbackUrl, _ = common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))

// registerFailback register failbackCluster to cluster extension.
func registerFailback(invoker *mock.MockInvoker) protocol.Invoker {
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster/failfast/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
)

var failfastUrl, _ = common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))

// registerFailfast register failfastCluster to cluster extension.
func registerFailfast(invoker *mock.MockInvoker) protocol.Invoker {
Expand Down
8 changes: 4 additions & 4 deletions cluster/cluster/failover/cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@ func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.I

func getRetries(invokers []protocol.Invoker, methodName string) int {
if len(invokers) <= 0 {
return constant.DEFAULT_RETRIES_INT
return constant.DefaultRetriesInt
}

url := invokers[0].GetURL()
// get reties
retriesConfig := url.GetParam(constant.RETRIES_KEY, constant.DEFAULT_RETRIES)
retriesConfig := url.GetParam(constant.RetriesKey, constant.DefaultRetries)
// Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.RETRIES_KEY, ""); len(v) != 0 {
if v := url.GetMethodParam(methodName, constant.RetriesKey, ""); len(v) != 0 {
retriesConfig = v
}

retries, err := strconv.Atoi(retriesConfig)
if err != nil || retries < 0 {
logger.Error("Your retries config is invalid,pls do a check. And will use the default retries configuration instead.")
retries = constant.DEFAULT_RETRIES_INT
retries = constant.DefaultRetriesInt
}

if retries > len(invokers) {
Expand Down
6 changes: 3 additions & 3 deletions cluster/cluster/failover/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestFailoverInvokeFail(t *testing.T) {
// nolint
func TestFailoverInvoke1(t *testing.T) {
urlParams := url.Values{}
urlParams.Set(constant.RETRIES_KEY, "3")
urlParams.Set(constant.RetriesKey, "3")
result := normalInvoke(4, urlParams)
assert.NoError(t, result.Error())
clusterpkg.Count = 0
Expand All @@ -86,8 +86,8 @@ func TestFailoverInvoke1(t *testing.T) {
// nolint
func TestFailoverInvoke2(t *testing.T) {
urlParams := url.Values{}
urlParams.Set(constant.RETRIES_KEY, "2")
urlParams.Set("methods.test."+constant.RETRIES_KEY, "3")
urlParams.Set(constant.RetriesKey, "2")
urlParams.Set("methods.test."+constant.RetriesKey, "3")

ivc := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("test"))
result := normalInvoke(4, urlParams, ivc)
Expand Down
4 changes: 2 additions & 2 deletions cluster/cluster/failsafe/cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.I
url := invokers[0].GetURL()
methodName := invocation.MethodName()
// Get the service loadbalance config
lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE)
lb := url.GetParam(constant.LoadbalanceKey, constant.DefaultLoadbalance)
// Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" {
if v := url.GetMethodParam(methodName, constant.LoadbalanceKey, ""); v != "" {
lb = v
}
loadbalance := extension.GetLoadbalance(lb)
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster/failsafe/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
)

var failsafeUrl, _ = common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))

// registerFailsafe register failsafeCluster to cluster extension.
func registerFailsafe(invoker *mock.MockInvoker) protocol.Invoker {
Expand Down
4 changes: 2 additions & 2 deletions cluster/cluster/forking/cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.I
}

var selected []protocol.Invoker
forks := invoker.GetURL().GetParamByIntValue(constant.FORKS_KEY, constant.DEFAULT_FORKS)
timeouts := invoker.GetURL().GetParamInt(constant.TIMEOUT_KEY, constant.DEFAULT_TIMEOUT)
forks := invoker.GetURL().GetParamByIntValue(constant.ForksKey, constant.DefaultForks)
timeouts := invoker.GetURL().GetParamInt(constant.TimeoutKey, constant.DefaultTimeout)
if forks < 0 || forks > len(invokers) {
selected = invokers
} else {
Expand Down
10 changes: 5 additions & 5 deletions cluster/cluster/forking/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
)

var forkingUrl, _ = common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))

func registerForking(mockInvokers ...*mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance(constant.LoadBalanceKeyRoundRobin, roundrobin.NewLoadBalance)
Expand All @@ -71,8 +71,8 @@ func TestForkingInvokeSuccess(t *testing.T) {
invokers := make([]*mock.MockInvoker, 0)

mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}}
forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
// forkingUrl.AddParam(constant.TIMEOUT_KEY, strconv.Itoa(constant.DEFAULT_TIMEOUT))
forkingUrl.AddParam(constant.ForksKey, strconv.Itoa(3))
// forkingUrl.AddParam(constant.TimeoutKey, strconv.Itoa(constant.DefaultTimeout))

var wg sync.WaitGroup
wg.Add(2)
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestForkingInvokeTimeout(t *testing.T) {
invokers := make([]*mock.MockInvoker, 0)

mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}}
forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
forkingUrl.AddParam(constant.ForksKey, strconv.Itoa(3))

var wg sync.WaitGroup
wg.Add(2)
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestForkingInvokeHalfTimeout(t *testing.T) {
invokers := make([]*mock.MockInvoker, 0)

mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}}
forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
forkingUrl.AddParam(constant.ForksKey, strconv.Itoa(3))

var wg sync.WaitGroup
wg.Add(2)
Expand Down
Loading

0 comments on commit 5cd1a52

Please sign in to comment.