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/01/04 07:46:39 UTC
[dubbo-go] branch develop updated (644fac3 -> b6022bb)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git.
omit 644fac3 fix ctx linter error
new b6022bb fix ctx linter error
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 (644fac3)
\
N -- N -- N refs/heads/develop (b6022bb)
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:
common/url.go | 8 +++++---
common/url_test.go | 42 +++++++++++++++++++++++++++++++++---------
2 files changed, 38 insertions(+), 12 deletions(-)
[dubbo-go] 01/01: fix ctx linter error
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit b6022bbd868305854f51e07312d8d5c3eacdea03
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Mon Jan 4 15:06:32 2021 +0800
fix ctx linter error
---
common/constant/key.go | 2 +-
common/url.go | 8 +++--
common/url_test.go | 42 +++++++++++++++++-----
config_center/apollo/listener.go | 2 +-
.../tps/tps_limiter_method_service_test.go | 2 +-
remoting/getty/listener_test.go | 6 ++--
6 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/common/constant/key.go b/common/constant/key.go
index 12e3096..50aea81 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -200,7 +200,7 @@ const (
)
const (
- TRACING_REMOTE_SPAN_CTX = "tracing.remote.span.ctx"
+ TRACING_REMOTE_SPAN_CTX = DubboCtxKey("tracing.remote.span.ctx")
)
// Use for router module
diff --git a/common/url.go b/common/url.go
index 87cacfd..ac49465 100644
--- a/common/url.go
+++ b/common/url.go
@@ -90,9 +90,7 @@ type baseUrl struct {
Location string // ip+port
Ip string
Port string
- //url.Values is not safe map, add to avoid concurrent map read and map write error
- paramsLock sync.RWMutex
- params url.Values
+
PrimitiveURL string
}
@@ -116,6 +114,10 @@ type URL struct {
noCopy noCopy
baseUrl
+ //url.Values is not safe map, add to avoid concurrent map read and map write error
+ paramsLock sync.RWMutex
+ params url.Values
+
Path string // like /com.ikurento.dubbo.UserProvider
Username string
Password string
diff --git a/common/url_test.go b/common/url_test.go
index 4008f6a..c645f1a 100644
--- a/common/url_test.go
+++ b/common/url_test.go
@@ -161,7 +161,10 @@ func TestURLEqual(t *testing.T) {
func TestURLGetParam(t *testing.T) {
params := url.Values{}
params.Set("key", "value")
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetParam("key", "default")
assert.Equal(t, "value", v)
@@ -172,8 +175,11 @@ func TestURLGetParam(t *testing.T) {
func TestURLGetParamInt(t *testing.T) {
params := url.Values{}
- params.Set("key", "")
- u := URL{baseUrl: baseUrl{params: params}}
+ params.Set("key", "value")
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetParamInt("key", 1)
assert.Equal(t, int64(1), v)
@@ -185,7 +191,10 @@ func TestURLGetParamInt(t *testing.T) {
func TestURLGetParamIntValue(t *testing.T) {
params := url.Values{}
params.Set("key", "0")
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetParamInt("key", 1)
assert.Equal(t, int64(0), v)
@@ -197,7 +206,10 @@ func TestURLGetParamIntValue(t *testing.T) {
func TestURLGetParamBool(t *testing.T) {
params := url.Values{}
params.Set("force", "true")
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetParamBool("force", false)
assert.Equal(t, true, v)
@@ -210,7 +222,10 @@ func TestURLGetParamAndDecoded(t *testing.T) {
rule := "host = 2.2.2.2,1.1.1.1,3.3.3.3 & host !=1.1.1.1 => host = 1.2.3.4"
params := url.Values{}
params.Set("rule", base64.URLEncoding.EncodeToString([]byte(rule)))
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v, _ := u.GetParamAndDecoded("rule")
assert.Equal(t, rule, v)
}
@@ -247,7 +262,10 @@ func TestURLToMap(t *testing.T) {
func TestURLGetMethodParamInt(t *testing.T) {
params := url.Values{}
params.Set("methods.GetValue.timeout", "3")
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetMethodParamInt("GetValue", "timeout", 1)
assert.Equal(t, int64(3), v)
@@ -259,7 +277,10 @@ func TestURLGetMethodParamInt(t *testing.T) {
func TestURLGetMethodParam(t *testing.T) {
params := url.Values{}
params.Set("methods.GetValue.timeout", "3s")
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetMethodParam("GetValue", "timeout", "1s")
assert.Equal(t, "3s", v)
@@ -271,7 +292,10 @@ func TestURLGetMethodParam(t *testing.T) {
func TestURLGetMethodParamBool(t *testing.T) {
params := url.Values{}
params.Set("methods.GetValue.async", "true")
- u := URL{baseUrl: baseUrl{params: params}}
+
+ u := URL{}
+ u.SetParams(params)
+
v := u.GetMethodParamBool("GetValue", "async", false)
assert.Equal(t, true, v)
diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go
index ace5ed0..44d3255 100644
--- a/config_center/apollo/listener.go
+++ b/config_center/apollo/listener.go
@@ -36,7 +36,7 @@ type apolloListener struct {
// nolint
func newApolloListener() *apolloListener {
return &apolloListener{
- listeners: make(map[config_center.ConfigurationListener]struct{}, 0),
+ listeners: make(map[config_center.ConfigurationListener]struct{}),
}
}
diff --git a/filter/filter_impl/tps/tps_limiter_method_service_test.go b/filter/filter_impl/tps/tps_limiter_method_service_test.go
index a70287e..4ff0a23 100644
--- a/filter/filter_impl/tps/tps_limiter_method_service_test.go
+++ b/filter/filter_impl/tps/tps_limiter_method_service_test.go
@@ -113,7 +113,7 @@ func TestMethodServiceTpsLimiterImplIsAllowableMethodLevelOverride(t *testing.T)
func TestMethodServiceTpsLimiterImplIsAllowableBothMethodAndService(t *testing.T) {
methodName := "hello3"
methodConfigPrefix := "methods." + methodName + "."
- invoc := invocation.NewRPCInvocation(methodName, []interface{}{"OK"}, make(map[string]interface{}, 0))
+ invoc := invocation.NewRPCInvocation(methodName, []interface{}{"OK"}, make(map[string]interface{}))
ctrl := gomock.NewController(t)
defer ctrl.Finish()
diff --git a/remoting/getty/listener_test.go b/remoting/getty/listener_test.go
index 956ecf9..2700ed8 100644
--- a/remoting/getty/listener_test.go
+++ b/remoting/getty/listener_test.go
@@ -23,14 +23,14 @@ import (
)
import (
+ "github.com/opentracing/opentracing-go"
+ "github.com/opentracing/opentracing-go/mocktracer"
"github.com/stretchr/testify/assert"
)
import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/protocol/invocation"
- "github.com/opentracing/opentracing-go"
- "github.com/opentracing/opentracing-go/mocktracer"
)
// test rebuild the ctx
@@ -63,7 +63,7 @@ func TestRebuildCtx(t *testing.T) {
// Once we decided to transfer more context's key-value, we should change this.
// now we only support rebuild the tracing context
func rebuildCtx(inv *invocation.RPCInvocation) context.Context {
- ctx := context.WithValue(context.Background(), "attachment", inv.Attachments())
+ ctx := context.WithValue(context.Background(), constant.DubboCtxKey("attachment"), inv.Attachments())
// actually, if user do not use any opentracing framework, the err will not be nil.
spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,