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 2020/12/27 05:54:23 UTC
[dubbo-go] 01/01: lint
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch imp/lint
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit 36352ff5914f24ff811ccd4cdaa2794715591c0c
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sun Dec 27 13:15:22 2020 +0800
lint
---
.github/workflows/github-actions.yml | 2 +-
cluster/cluster_impl/failback_cluster_invoker.go | 4 +-
cluster/router/condition/file_test.go | 3 +-
.../healthcheck/default_health_check_test.go | 6 +-
cluster/router/tag/tag_router_test.go | 6 +-
common/logger/logger.go | 2 +-
common/proxy/proxy_test.go | 2 +-
common/url.go | 4 +-
config/config_loader_test.go | 12 +-
config/service_config_test.go | 2 +-
config_center/nacos/client.go | 5 +-
config_center/zookeeper/impl_test.go | 6 +-
.../filter_impl/auth/default_authenticator_test.go | 2 +-
filter/filter_impl/auth/sign_util.go | 2 +-
metadata/report/delegate/delegate_report.go | 12 +-
metadata/report/zookeeper/report_test.go | 12 +-
metadata/service/inmemory/service_proxy_test.go | 34 ++-
metadata/service/inmemory/service_test.go | 32 ++-
protocol/dubbo/hessian2/const.go | 16 +-
protocol/dubbo/hessian2/hessian_dubbo_test.go | 2 +
protocol/dubbo/hessian2/hessian_request.go | 16 +-
protocol/dubbo/impl/const.go | 249 ++++++++++----------
protocol/dubbo/opentracing.go | 14 +-
.../grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go | 6 +-
protocol/jsonrpc/json.go | 12 +-
registry/base_configuration_listener.go | 2 +-
registry/base_registry.go | 3 +
registry/kubernetes/listener_test.go | 262 ++++++++++-----------
remoting/getty/getty_client.go | 4 +-
remoting/getty/getty_client_test.go | 14 +-
remoting/getty/opentracing.go | 14 +-
remoting/getty/pool.go | 10 +-
remoting/nacos/builder_test.go | 6 +-
remoting/zookeeper/client_test.go | 22 +-
34 files changed, 423 insertions(+), 377 deletions(-)
diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml
index 7b082d1..478171e 100644
--- a/.github/workflows/github-actions.yml
+++ b/.github/workflows/github-actions.yml
@@ -58,7 +58,7 @@ jobs:
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.33.0
- name: Run Linter
- run: golangci-lint run --timeout=10m -v
+ run: golangci-lint run --timeout=5m -v
- name: Verify
run: |
diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go
index 62f4804..9a430be 100644
--- a/cluster/cluster_impl/failback_cluster_invoker.go
+++ b/cluster/cluster_impl/failback_cluster_invoker.go
@@ -122,7 +122,7 @@ func (invoker *failbackClusterInvoker) checkRetry(retryTask *retryTimerTask, err
logger.Errorf("Failed retry times exceed threshold (%v), We have to abandon, invocation-> %v.\n",
retryTask.retries, retryTask.invocation)
} else {
- invoker.taskList.Put(retryTask)
+ _ = invoker.taskList.Put(retryTask)
}
}
@@ -162,7 +162,7 @@ func (invoker *failbackClusterInvoker) Invoke(ctx context.Context, invocation pr
}
timerTask := newRetryTimerTask(loadBalance, invocation, invokers, ivk)
- invoker.taskList.Put(timerTask)
+ _ = invoker.taskList.Put(timerTask)
logger.Errorf("Failback to invoke the method %v in the service %v, wait for retry in background. Ignored exception: %v.\n",
methodName, url.Service(), result.Error().Error())
diff --git a/cluster/router/condition/file_test.go b/cluster/router/condition/file_test.go
index bd19a0d..e38cdb6 100644
--- a/cluster/router/condition/file_test.go
+++ b/cluster/router/condition/file_test.go
@@ -115,7 +115,7 @@ func TestParseServiceRouterKey(t *testing.T) {
assert.Equal(t, "", ver)
testString = "grp:mock-service:123"
- grp, srv, ver, err = parseServiceRouterKey(testString)
+ _, _, _, err = parseServiceRouterKey(testString)
assert.Error(t, err)
testString = ""
@@ -123,4 +123,5 @@ func TestParseServiceRouterKey(t *testing.T) {
assert.Equal(t, "", grp)
assert.Equal(t, "", srv)
assert.Equal(t, "", ver)
+ assert.Nil(t, err)
}
diff --git a/cluster/router/healthcheck/default_health_check_test.go b/cluster/router/healthcheck/default_health_check_test.go
index 39827c5..2fd06e9 100644
--- a/cluster/router/healthcheck/default_health_check_test.go
+++ b/cluster/router/healthcheck/default_health_check_test.go
@@ -55,7 +55,7 @@ func TestDefaultHealthCheckerIsHealthy(t *testing.T) {
request(url, healthCheckMethodTest, 0, true, false)
}
hc = NewDefaultHealthChecker(url).(*DefaultHealthChecker)
- healthy = hc.IsHealthy(invoker)
+ _ = hc.IsHealthy(invoker)
// the outgoing request is more than OUTSTANDING_REQUEST_COUNT_LIMIT, go to unhealthy
assert.False(t, hc.IsHealthy(invoker))
@@ -66,12 +66,12 @@ func TestDefaultHealthCheckerIsHealthy(t *testing.T) {
url.SetParam(constant.SUCCESSIVE_FAILED_REQUEST_THRESHOLD_KEY, "10")
url.SetParam(constant.OUTSTANDING_REQUEST_COUNT_LIMIT_KEY, "1000")
hc = NewDefaultHealthChecker(url).(*DefaultHealthChecker)
- healthy = hc.IsHealthy(invoker)
+ _ = hc.IsHealthy(invoker)
assert.False(t, hc.IsHealthy(invoker))
// reset successive failed count and go to healthy
request(url, healthCheckMethodTest, 0, false, true)
- healthy = hc.IsHealthy(invoker)
+ _ = hc.IsHealthy(invoker)
assert.True(t, hc.IsHealthy(invoker))
}
diff --git a/cluster/router/tag/tag_router_test.go b/cluster/router/tag/tag_router_test.go
index 3f7b979..fdb60a4 100644
--- a/cluster/router/tag/tag_router_test.go
+++ b/cluster/router/tag/tag_router_test.go
@@ -73,8 +73,8 @@ const (
)
var (
- zkFormat = "zookeeper://%s:%d"
- conditionFormat = "condition://%s/com.foo.BarService"
+ zkFormat = "zookeeper://%s:%d"
+ //conditionFormat = "condition://%s/com.foo.BarService"
)
// MockInvoker is only mock the Invoker to support test tagRouter
@@ -310,7 +310,7 @@ tags:
func (suite *DynamicTagRouter) TearDownTest() {
suite.zkClient.Close()
- suite.testCluster.Stop()
+ _ = suite.testCluster.Stop()
}
func (suite *DynamicTagRouter) TestDynamicTagRouterSetByIPv4() {
diff --git a/common/logger/logger.go b/common/logger/logger.go
index 63eda23..2cf2440 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -163,6 +163,6 @@ type OpsLogger interface {
// SetLoggerLevel use for set logger level
func (dl *DubboLogger) SetLoggerLevel(level string) {
l := new(zapcore.Level)
- l.Set(level)
+ _ = l.Set(level)
dl.dynamicLevel.SetLevel(*l)
}
diff --git a/common/proxy/proxy_test.go b/common/proxy/proxy_test.go
index c6f6596..a295f91 100644
--- a/common/proxy/proxy_test.go
+++ b/common/proxy/proxy_test.go
@@ -149,7 +149,7 @@ func (bi *TestProxyInvoker) Invoke(context context.Context, inv protocol.Invocat
rpcInv := inv.(*invocation.RPCInvocation)
mapV := inv.Attachments()
mapV["TestProxyInvoker"] = "TestProxyInvokerValue"
- hessian2.ReflectResponse(mapV, rpcInv.Reply())
+ _ = hessian2.ReflectResponse(mapV, rpcInv.Reply())
return &protocol.RPCResult{
Rest: inv.Arguments(),
}
diff --git a/common/url.go b/common/url.go
index 1ea2bc4..47d64c4 100644
--- a/common/url.go
+++ b/common/url.go
@@ -680,7 +680,7 @@ func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL {
// Clone will copy the url
func (c *URL) Clone() *URL {
newUrl := &URL{}
- copier.Copy(newUrl, c)
+ _ = copier.Copy(newUrl, c)
newUrl.params = url.Values{}
c.RangeParams(func(key, value string) bool {
newUrl.SetParam(key, value)
@@ -691,7 +691,7 @@ func (c *URL) Clone() *URL {
func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL {
newUrl := &URL{}
- copier.Copy(newUrl, c)
+ _ = copier.Copy(newUrl, c)
newUrl.params = url.Values{}
c.RangeParams(func(key, value string) bool {
if !excludeParams.Contains(key) {
diff --git a/config/config_loader_test.go b/config/config_loader_test.go
index c3c3eb9..3169f2c 100644
--- a/config/config_loader_test.go
+++ b/config/config_loader_test.go
@@ -143,7 +143,7 @@ func TestLoadWithSingleReg(t *testing.T) {
conServices = map[string]common.RPCService{}
proServices = map[string]common.RPCService{}
- common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0"))
+ _ = common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0"))
consumerConfig = nil
providerConfig = nil
}
@@ -182,7 +182,7 @@ func TestWithNoRegLoad(t *testing.T) {
conServices = map[string]common.RPCService{}
proServices = map[string]common.RPCService{}
- common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0"))
+ _ = common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0"))
consumerConfig = nil
providerConfig = nil
}
@@ -203,10 +203,10 @@ func TestConfigLoaderWithConfigCenter(t *testing.T) {
assert.Equal(t, ProviderConfig{}, GetProviderConfig())
err = ConsumerInit(conPath)
- configCenterRefreshConsumer()
+ _ = configCenterRefreshConsumer()
assert.NoError(t, err)
err = ProviderInit(proPath)
- configCenterRefreshProvider()
+ _ = configCenterRefreshProvider()
assert.NoError(t, err)
assert.NotNil(t, consumerConfig)
@@ -257,12 +257,12 @@ func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) {
err = ConsumerInit(conPath)
checkApplicationName(consumerConfig.ApplicationConfig)
- configCenterRefreshConsumer()
+ _ = configCenterRefreshConsumer()
checkRegistries(consumerConfig.Registries, consumerConfig.Registry)
assert.NoError(t, err)
err = ProviderInit(proPath)
checkApplicationName(providerConfig.ApplicationConfig)
- configCenterRefreshProvider()
+ _ = configCenterRefreshProvider()
checkRegistries(providerConfig.Registries, providerConfig.Registry)
assert.NoError(t, err)
diff --git a/config/service_config_test.go b/config/service_config_test.go
index 61c8864..2d294d9 100644
--- a/config/service_config_test.go
+++ b/config/service_config_test.go
@@ -176,7 +176,7 @@ func TestExport(t *testing.T) {
service := providerConfig.Services[i]
service.Implement(&MockService{})
service.Protocols = providerConfig.Protocols
- service.Export()
+ _ = service.Export()
}
providerConfig = nil
}
diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go
index f3942c0..43c8959 100644
--- a/config_center/nacos/client.go
+++ b/config_center/nacos/client.go
@@ -18,7 +18,6 @@
package nacos
import (
- "path/filepath"
"strconv"
"strings"
"sync"
@@ -39,7 +38,9 @@ import (
)
// Nacos Log dir, it can be override when creating client by config_center.log_dir
-var logDir = filepath.Join("logs", "nacos", "log")
+//var (
+// logDir = filepath.Join("logs", "nacos", "log")
+//)
// NacosClient Nacos client
type NacosClient struct {
diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go
index d4a9de4..b7224d1 100644
--- a/config_center/zookeeper/impl_test.go
+++ b/config_center/zookeeper/impl_test.go
@@ -105,11 +105,11 @@ func TestGetConfig(t *testing.T) {
m, err := reg.Parser().Parse(configs)
assert.NoError(t, err)
assert.Equal(t, "5s", m["dubbo.consumer.request_timeout"])
- configs, err = reg.GetProperties(dubboPropertyFileName)
+ _, err = reg.GetProperties(dubboPropertyFileName)
assert.Error(t, err)
- configs, err = reg.GetInternalProperty(dubboPropertyFileName)
+ _, err = reg.GetInternalProperty(dubboPropertyFileName)
assert.Error(t, err)
- configs, err = reg.GetRule(dubboPropertyFileName)
+ _, err = reg.GetRule(dubboPropertyFileName)
assert.Error(t, err)
}
diff --git a/filter/filter_impl/auth/default_authenticator_test.go b/filter/filter_impl/auth/default_authenticator_test.go
index 37c7e9d..c6379b9 100644
--- a/filter/filter_impl/auth/default_authenticator_test.go
+++ b/filter/filter_impl/auth/default_authenticator_test.go
@@ -113,7 +113,7 @@ func Test_getAccessKeyPairFailed(t *testing.T) {
common.WithParamsValue(constant.SECRET_ACCESS_KEY_KEY, "skey"),
common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"), common.WithParamsValue(constant.ACCESS_KEY_STORAGE_KEY, "dubbo"))
_, e = getAccessKeyPair(invcation, testurl)
-
+ assert.Nil(t, nil)
}
func Test_getSignatureWithinParams(t *testing.T) {
diff --git a/filter/filter_impl/auth/sign_util.go b/filter/filter_impl/auth/sign_util.go
index 45170bb..eb319da 100644
--- a/filter/filter_impl/auth/sign_util.go
+++ b/filter/filter_impl/auth/sign_util.go
@@ -56,7 +56,7 @@ func toBytes(data []interface{}) ([]byte, error) {
func doSign(bytes []byte, key string) string {
mac := hmac.New(sha256.New, []byte(key))
- mac.Write(bytes)
+ _, _ = mac.Write(bytes)
signature := mac.Sum(nil)
return base64.URLEncoding.EncodeToString(signature)
}
diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go
index 836a8f9..c72e733 100644
--- a/metadata/report/delegate/delegate_report.go
+++ b/metadata/report/delegate/delegate_report.go
@@ -220,7 +220,9 @@ func (mr *MetadataReport) SaveServiceMetadata(identifier *identifier.ServiceMeta
if mr.syncReport {
return report.SaveServiceMetadata(identifier, url)
}
- go report.SaveServiceMetadata(identifier, url)
+ go func() {
+ _ = report.SaveServiceMetadata(identifier, url)
+ }()
return nil
}
@@ -230,7 +232,9 @@ func (mr *MetadataReport) RemoveServiceMetadata(identifier *identifier.ServiceMe
if mr.syncReport {
return report.RemoveServiceMetadata(identifier)
}
- go report.RemoveServiceMetadata(identifier)
+ go func() {
+ _ = report.RemoveServiceMetadata(identifier)
+ }()
return nil
}
@@ -255,7 +259,9 @@ func (mr *MetadataReport) SaveSubscribedData(identifier *identifier.SubscriberMe
if mr.syncReport {
return report.SaveSubscribedData(identifier, string(bytes))
}
- go report.SaveSubscribedData(identifier, string(bytes))
+ go func() {
+ _ = report.SaveSubscribedData(identifier, string(bytes))
+ }()
return nil
}
diff --git a/metadata/report/zookeeper/report_test.go b/metadata/report/zookeeper/report_test.go
index adedaaa..634c8b2 100644
--- a/metadata/report/zookeeper/report_test.go
+++ b/metadata/report/zookeeper/report_test.go
@@ -144,19 +144,21 @@ func (suite *zookeeperMetadataReportTestSuite) testGetServiceDefinition() {
func test1(t *testing.T) {
testCluster, err := zk.StartTestCluster(1, nil, nil)
assert.NoError(t, err)
- defer testCluster.Stop()
+ defer func() {
+ _ = testCluster.Stop()
+ }()
- url := newProviderRegistryUrl("127.0.0.1", testCluster.Servers[0].Port)
+ rURL := newProviderRegistryUrl("127.0.0.1", testCluster.Servers[0].Port)
mf := extension.GetMetadataReportFactory("zookeeper")
- m := mf.CreateMetadataReport(url)
+ m := mf.CreateMetadataReport(rURL)
suite := newZookeeperMetadataReportTestSuite(t, m)
suite.testStoreProviderMetadata()
suite.testStoreConsumerMetadata()
- suite.testSaveServiceMetadata(url)
+ suite.testSaveServiceMetadata(rURL)
suite.testGetExportedURLs()
suite.testRemoveServiceMetadata()
- suite.testSaveSubscribedData(url)
+ suite.testSaveSubscribedData(rURL)
suite.testGetSubscribedURLs()
suite.testGetServiceDefinition()
}
diff --git a/metadata/service/inmemory/service_proxy_test.go b/metadata/service/inmemory/service_proxy_test.go
index f7fc8fd..6fceb1d 100644
--- a/metadata/service/inmemory/service_proxy_test.go
+++ b/metadata/service/inmemory/service_proxy_test.go
@@ -48,19 +48,29 @@ func TestMetadataServiceProxy_GetExportedURLs(t *testing.T) {
// when we implement them, adding UT
func TestNewMetadataService(t *testing.T) {
pxy := createPxy()
- pxy.ServiceName()
- pxy.PublishServiceDefinition(&common.URL{})
- pxy.GetServiceDefinition(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
- pxy.Version()
- pxy.GetSubscribedURLs()
- pxy.UnsubscribeURL(&common.URL{})
- pxy.GetServiceDefinitionByServiceKey("any")
- pxy.ExportURL(&common.URL{})
- pxy.SubscribeURL(&common.URL{})
+ _, err := pxy.ServiceName()
+ assert.Nil(t, err)
+ err = pxy.PublishServiceDefinition(&common.URL{})
+ assert.Nil(t, err)
+ _, err = pxy.GetServiceDefinition(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
+ assert.Nil(t, err)
+ _, err = pxy.Version()
+ assert.Nil(t, err)
+ _, err = pxy.GetSubscribedURLs()
+ assert.Nil(t, err)
+ err = pxy.UnsubscribeURL(&common.URL{})
+ assert.Nil(t, err)
+ _, err = pxy.GetServiceDefinitionByServiceKey("any")
+ assert.Nil(t, err)
+ _, err = pxy.ExportURL(&common.URL{})
+ assert.Nil(t, err)
+ _, err = pxy.SubscribeURL(&common.URL{})
+ assert.Nil(t, err)
pxy.MethodMapper()
- pxy.UnexportURL(&common.URL{})
- pxy.RefreshMetadata(constant.ANY_VALUE, constant.ANY_VALUE)
-
+ err = pxy.UnexportURL(&common.URL{})
+ assert.Nil(t, err)
+ _, err = pxy.RefreshMetadata(constant.ANY_VALUE, constant.ANY_VALUE)
+ assert.Nil(t, err)
}
func createPxy() service.MetadataService {
diff --git a/metadata/service/inmemory/service_test.go b/metadata/service/inmemory/service_test.go
index 256412c..3e087ae 100644
--- a/metadata/service/inmemory/service_test.go
+++ b/metadata/service/inmemory/service_test.go
@@ -10,7 +10,7 @@
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * WITHOUT WARRANTIES OR OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@@ -46,7 +46,8 @@ func TestMetadataService(t *testing.T) {
"owner=ZX&pid=1447&revision=0.0.1&side=provider&timeout=3000×tamp=1556509797245&group=%v&version=%v&bean.name=%v",
protocol, serviceName, group, version, beanName))
assert.NoError(t, err)
- mts.ExportURL(u2)
+ _, err = mts.ExportURL(u2)
+ assert.Nil(t, err)
u3, err := common.NewURL(fmt.Sprintf(
"%v://127.0.0.1:20000/com.ikurento.user.UserProvider3?anyhost=true&"+
@@ -55,7 +56,8 @@ func TestMetadataService(t *testing.T) {
"owner=ZX&pid=1447&revision=0.0.1&side=provider&timeout=3000×tamp=1556509797245&group=%v&version=%v&bean.name=%v",
protocol, serviceName, group, version, beanName))
assert.NoError(t, err)
- mts.ExportURL(u3)
+ _, err = mts.ExportURL(u3)
+ assert.Nil(t, err)
u, err := common.NewURL(fmt.Sprintf(
"%v://127.0.0.1:20000/com.ikurento.user.UserProvider1?anyhost=true&"+
@@ -64,26 +66,36 @@ func TestMetadataService(t *testing.T) {
"owner=ZX&pid=1447&revision=0.0.1&side=provider&timeout=3000×tamp=1556509797245&group=%v&version=%v&bean.name=%v",
protocol, serviceName, group, version, beanName))
assert.NoError(t, err)
- mts.ExportURL(u)
+ _, err = mts.ExportURL(u)
+ assert.Nil(t, err)
+
list, _ := mts.GetExportedURLs(serviceName, group, version, protocol)
assert.Equal(t, 3, len(list))
- mts.SubscribeURL(u)
+ _, err = mts.SubscribeURL(u)
+ assert.Nil(t, err)
- mts.SubscribeURL(u)
+ _, err = mts.ExportURL(u)
+ assert.Nil(t, err)
+ _, err = mts.SubscribeURL(u)
+ assert.Nil(t, err)
list2, _ := mts.GetSubscribedURLs()
assert.Equal(t, 1, len(list2))
- mts.UnexportURL(u)
+ err = mts.UnexportURL(u)
+ assert.Nil(t, err)
list3, _ := mts.GetExportedURLs(serviceName, group, version, protocol)
assert.Equal(t, 2, len(list3))
- mts.UnsubscribeURL(u)
+ err = mts.UnsubscribeURL(u)
+ assert.Nil(t, err)
list4, _ := mts.GetSubscribedURLs()
assert.Equal(t, 0, len(list4))
userProvider := &definition.UserProvider{}
- common.ServiceMap.Register(serviceName, protocol, group, version, userProvider)
- mts.PublishServiceDefinition(u)
+ _, err = common.ServiceMap.Register(serviceName, protocol, group, version, userProvider)
+ assert.Nil(t, err)
+ err = mts.PublishServiceDefinition(u)
+ assert.Nil(t, err)
expected := "{\"CanonicalName\":\"com.ikurento.user.UserProvider\",\"CodeSource\":\"\"," +
"\"Methods\":[{\"Name\":\"GetUser\",\"ParameterTypes\":[\"slice\"],\"ReturnType\":\"ptr\"," +
"\"Parameters\":null}],\"Types\":null}"
diff --git a/protocol/dubbo/hessian2/const.go b/protocol/dubbo/hessian2/const.go
index 74a00b6..7744776 100644
--- a/protocol/dubbo/hessian2/const.go
+++ b/protocol/dubbo/hessian2/const.go
@@ -80,14 +80,14 @@ const (
INT_SHORT_MAX = 0x3ffff
BC_INT_SHORT_ZERO = byte(0xd4)
- BC_LIST_VARIABLE = byte(0x55)
- BC_LIST_FIXED = byte('V')
- BC_LIST_VARIABLE_UNTYPED = byte(0x57)
- BC_LIST_FIXED_UNTYPED = byte(0x58)
- _listFixedTypedLenTagMin = byte(0x70)
- _listFixedTypedLenTagMax = byte(0x77)
- _listFixedUntypedLenTagMin = byte(0x78)
- _listFixedUntypedLenTagMax = byte(0x7f)
+ BC_LIST_VARIABLE = byte(0x55)
+ BC_LIST_FIXED = byte('V')
+ BC_LIST_VARIABLE_UNTYPED = byte(0x57)
+ BC_LIST_FIXED_UNTYPED = byte(0x58)
+ //_listFixedTypedLenTagMin = byte(0x70)
+ //_listFixedTypedLenTagMax = byte(0x77)
+ //_listFixedUntypedLenTagMin = byte(0x78)
+ //_listFixedUntypedLenTagMax = byte(0x7f)
BC_LIST_DIRECT = byte(0x70)
BC_LIST_DIRECT_UNTYPED = byte(0x78)
diff --git a/protocol/dubbo/hessian2/hessian_dubbo_test.go b/protocol/dubbo/hessian2/hessian_dubbo_test.go
index 13dab92..2e7bce6 100644
--- a/protocol/dubbo/hessian2/hessian_dubbo_test.go
+++ b/protocol/dubbo/hessian2/hessian_dubbo_test.go
@@ -80,6 +80,7 @@ func doTestHessianEncodeHeader(t *testing.T, packageType PackageType, responseSt
func doTestResponse(t *testing.T, packageType PackageType, responseStatus byte, body interface{}, decodedResponse *DubboResponse, assertFunc func()) {
resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body)
+ assert.Nil(t, err)
codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp)))
@@ -163,6 +164,7 @@ func TestResponse(t *testing.T) {
func doTestRequest(t *testing.T, packageType PackageType, responseStatus byte, body interface{}) {
resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body)
+ assert.Nil(t, err)
codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp)))
diff --git a/protocol/dubbo/hessian2/hessian_request.go b/protocol/dubbo/hessian2/hessian_request.go
index 4ebb4aa..3b026d9 100644
--- a/protocol/dubbo/hessian2/hessian_request.go
+++ b/protocol/dubbo/hessian2/hessian_request.go
@@ -216,23 +216,23 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte,
// body
//////////////////////////////////////////
if hb {
- encoder.Encode(nil)
+ _ = encoder.Encode(nil)
goto END
}
// dubbo version + path + version + method
- encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION)
- encoder.Encode(service.Path)
- encoder.Encode(service.Version)
- encoder.Encode(service.Method)
+ _ = encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION)
+ _ = encoder.Encode(service.Path)
+ _ = encoder.Encode(service.Version)
+ _ = encoder.Encode(service.Method)
// args = args type list + args value list
if types, err = getArgsTypeList(args); err != nil {
return nil, perrors.Wrapf(err, " PackRequest(args:%+v)", args)
}
- encoder.Encode(types)
+ _ = encoder.Encode(types)
for _, v := range args {
- encoder.Encode(v)
+ _ = encoder.Encode(v)
}
request.Attachments[PATH_KEY] = service.Path
@@ -247,7 +247,7 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte,
request.Attachments[TIMEOUT_KEY] = strconv.Itoa(int(service.Timeout / time.Millisecond))
}
- encoder.Encode(request.Attachments)
+ _ = encoder.Encode(request.Attachments)
END:
byteArray = encoder.Buffer()
diff --git a/protocol/dubbo/impl/const.go b/protocol/dubbo/impl/const.go
index 70d8bae..072cc95 100644
--- a/protocol/dubbo/impl/const.go
+++ b/protocol/dubbo/impl/const.go
@@ -28,10 +28,10 @@ const (
DUBBO = "dubbo"
)
-const (
- mask = byte(127)
- flag = byte(128)
-)
+//const (
+// mask = byte(127)
+// flag = byte(128)
+//)
const (
// Zero : byte zero
@@ -40,111 +40,111 @@ const (
// constansts
const (
- TAG_READ = int32(-1)
- ASCII_GAP = 32
- CHUNK_SIZE = 4096
- BC_BINARY = byte('B') // final chunk
- BC_BINARY_CHUNK = byte('A') // non-final chunk
-
- BC_BINARY_DIRECT = byte(0x20) // 1-byte length binary
- BINARY_DIRECT_MAX = byte(0x0f)
- BC_BINARY_SHORT = byte(0x34) // 2-byte length binary
- BINARY_SHORT_MAX = 0x3ff // 0-1023 binary
-
- BC_DATE = byte(0x4a) // 64-bit millisecond UTC date
- BC_DATE_MINUTE = byte(0x4b) // 32-bit minute UTC date
-
- BC_DOUBLE = byte('D') // IEEE 64-bit double
-
- BC_DOUBLE_ZERO = byte(0x5b)
- BC_DOUBLE_ONE = byte(0x5c)
- BC_DOUBLE_BYTE = byte(0x5d)
- BC_DOUBLE_SHORT = byte(0x5e)
- BC_DOUBLE_MILL = byte(0x5f)
-
- BC_FALSE = byte('F') // boolean false
-
- BC_INT = byte('I') // 32-bit int
-
- INT_DIRECT_MIN = -0x10
- INT_DIRECT_MAX = byte(0x2f)
- BC_INT_ZERO = byte(0x90)
-
- INT_BYTE_MIN = -0x800
- INT_BYTE_MAX = 0x7ff
- BC_INT_BYTE_ZERO = byte(0xc8)
-
- BC_END = byte('Z')
-
- INT_SHORT_MIN = -0x40000
- INT_SHORT_MAX = 0x3ffff
- BC_INT_SHORT_ZERO = byte(0xd4)
-
- BC_LIST_VARIABLE = byte(0x55)
- BC_LIST_FIXED = byte('V')
- BC_LIST_VARIABLE_UNTYPED = byte(0x57)
- BC_LIST_FIXED_UNTYPED = byte(0x58)
- _listFixedTypedLenTagMin = byte(0x70)
- _listFixedTypedLenTagMax = byte(0x77)
- _listFixedUntypedLenTagMin = byte(0x78)
- _listFixedUntypedLenTagMax = byte(0x7f)
-
- BC_LIST_DIRECT = byte(0x70)
- BC_LIST_DIRECT_UNTYPED = byte(0x78)
- LIST_DIRECT_MAX = byte(0x7)
-
- BC_LONG = byte('L') // 64-bit signed integer
- LONG_DIRECT_MIN = -0x08
- LONG_DIRECT_MAX = byte(0x0f)
- BC_LONG_ZERO = byte(0xe0)
-
- LONG_BYTE_MIN = -0x800
- LONG_BYTE_MAX = 0x7ff
- BC_LONG_BYTE_ZERO = byte(0xf8)
-
- LONG_SHORT_MIN = -0x40000
- LONG_SHORT_MAX = 0x3ffff
- BC_LONG_SHORT_ZERO = byte(0x3c)
-
- BC_LONG_INT = byte(0x59)
-
- BC_MAP = byte('M')
- BC_MAP_UNTYPED = byte('H')
-
- BC_NULL = byte('N') // x4e
-
- BC_OBJECT = byte('O')
- BC_OBJECT_DEF = byte('C')
-
- BC_OBJECT_DIRECT = byte(0x60)
- OBJECT_DIRECT_MAX = byte(0x0f)
-
- BC_REF = byte(0x51)
-
- BC_STRING = byte('S') // final string
- BC_STRING_CHUNK = byte('R') // non-final string
-
- BC_STRING_DIRECT = byte(0x00)
- STRING_DIRECT_MAX = byte(0x1f)
- BC_STRING_SHORT = byte(0x30)
- STRING_SHORT_MAX = 0x3ff
-
- BC_TRUE = byte('T')
-
- P_PACKET_CHUNK = byte(0x4f)
- P_PACKET = byte('P')
-
- P_PACKET_DIRECT = byte(0x80)
- PACKET_DIRECT_MAX = byte(0x7f)
-
- P_PACKET_SHORT = byte(0x70)
- PACKET_SHORT_MAX = 0xfff
- ARRAY_STRING = "[string"
- ARRAY_INT = "[int"
- ARRAY_DOUBLE = "[double"
- ARRAY_FLOAT = "[float"
- ARRAY_BOOL = "[boolean"
- ARRAY_LONG = "[long"
+ //TAG_READ = int32(-1)
+ //ASCII_GAP = 32
+ //CHUNK_SIZE = 4096
+ //BC_BINARY = byte('B') // final chunk
+ //BC_BINARY_CHUNK = byte('A') // non-final chunk
+ //
+ //BC_BINARY_DIRECT = byte(0x20) // 1-byte length binary
+ //BINARY_DIRECT_MAX = byte(0x0f)
+ //BC_BINARY_SHORT = byte(0x34) // 2-byte length binary
+ //BINARY_SHORT_MAX = 0x3ff // 0-1023 binary
+ //
+ //BC_DATE = byte(0x4a) // 64-bit millisecond UTC date
+ //BC_DATE_MINUTE = byte(0x4b) // 32-bit minute UTC date
+ //
+ //BC_DOUBLE = byte('D') // IEEE 64-bit double
+ //
+ //BC_DOUBLE_ZERO = byte(0x5b)
+ //BC_DOUBLE_ONE = byte(0x5c)
+ //BC_DOUBLE_BYTE = byte(0x5d)
+ //BC_DOUBLE_SHORT = byte(0x5e)
+ //BC_DOUBLE_MILL = byte(0x5f)
+ //
+ //BC_FALSE = byte('F') // boolean false
+ //
+ //BC_INT = byte('I') // 32-bit int
+ //
+ //INT_DIRECT_MIN = -0x10
+ //INT_DIRECT_MAX = byte(0x2f)
+ //BC_INT_ZERO = byte(0x90)
+ //
+ //INT_BYTE_MIN = -0x800
+ //INT_BYTE_MAX = 0x7ff
+ //BC_INT_BYTE_ZERO = byte(0xc8)
+ //
+ //BC_END = byte('Z')
+ //
+ //INT_SHORT_MIN = -0x40000
+ //INT_SHORT_MAX = 0x3ffff
+ //BC_INT_SHORT_ZERO = byte(0xd4)
+ //
+ //BC_LIST_VARIABLE = byte(0x55)
+ //BC_LIST_FIXED = byte('V')
+ //BC_LIST_VARIABLE_UNTYPED = byte(0x57)
+ //BC_LIST_FIXED_UNTYPED = byte(0x58)
+ //_listFixedTypedLenTagMin = byte(0x70)
+ //_listFixedTypedLenTagMax = byte(0x77)
+ //_listFixedUntypedLenTagMin = byte(0x78)
+ //_listFixedUntypedLenTagMax = byte(0x7f)
+ //
+ //BC_LIST_DIRECT = byte(0x70)
+ //BC_LIST_DIRECT_UNTYPED = byte(0x78)
+ //LIST_DIRECT_MAX = byte(0x7)
+ //
+ //BC_LONG = byte('L') // 64-bit signed integer
+ //LONG_DIRECT_MIN = -0x08
+ //LONG_DIRECT_MAX = byte(0x0f)
+ //BC_LONG_ZERO = byte(0xe0)
+ //
+ //LONG_BYTE_MIN = -0x800
+ //LONG_BYTE_MAX = 0x7ff
+ //BC_LONG_BYTE_ZERO = byte(0xf8)
+ //
+ //LONG_SHORT_MIN = -0x40000
+ //LONG_SHORT_MAX = 0x3ffff
+ //BC_LONG_SHORT_ZERO = byte(0x3c)
+ //
+ //BC_LONG_INT = byte(0x59)
+ //
+ //BC_MAP = byte('M')
+ //BC_MAP_UNTYPED = byte('H')
+ //
+ //BC_NULL = byte('N') // x4e
+ //
+ //BC_OBJECT = byte('O')
+ //BC_OBJECT_DEF = byte('C')
+ //
+ //BC_OBJECT_DIRECT = byte(0x60)
+ //OBJECT_DIRECT_MAX = byte(0x0f)
+ //
+ //BC_REF = byte(0x51)
+ //
+ //BC_STRING = byte('S') // final string
+ //BC_STRING_CHUNK = byte('R') // non-final string
+ //
+ //BC_STRING_DIRECT = byte(0x00)
+ //STRING_DIRECT_MAX = byte(0x1f)
+ //BC_STRING_SHORT = byte(0x30)
+ //STRING_SHORT_MAX = 0x3ff
+ //
+ //BC_TRUE = byte('T')
+ //
+ //P_PACKET_CHUNK = byte(0x4f)
+ //P_PACKET = byte('P')
+ //
+ //P_PACKET_DIRECT = byte(0x80)
+ //PACKET_DIRECT_MAX = byte(0x7f)
+ //
+ //P_PACKET_SHORT = byte(0x70)
+ //PACKET_SHORT_MAX = 0xfff
+ //ARRAY_STRING = "[string"
+ //ARRAY_INT = "[int"
+ //ARRAY_DOUBLE = "[double"
+ //ARRAY_FLOAT = "[float"
+ //ARRAY_BOOL = "[boolean"
+ //ARRAY_LONG = "[long"
PATH_KEY = "path"
GROUP_KEY = "group"
@@ -152,24 +152,24 @@ const (
VERSION_KEY = "version"
TIMEOUT_KEY = "timeout"
- STRING_NIL = ""
- STRING_TRUE = "true"
- STRING_FALSE = "false"
- STRING_ZERO = "0.0"
- STRING_ONE = "1.0"
+ //STRING_NIL = ""
+ //STRING_TRUE = "true"
+ //STRING_FALSE = "false"
+ //STRING_ZERO = "0.0"
+ //STRING_ONE = "1.0"
)
// ResponsePayload related consts
const (
- Response_OK byte = 20
- Response_CLIENT_TIMEOUT byte = 30
- Response_SERVER_TIMEOUT byte = 31
- Response_BAD_REQUEST byte = 40
- Response_BAD_RESPONSE byte = 50
- Response_SERVICE_NOT_FOUND byte = 60
- Response_SERVICE_ERROR byte = 70
- Response_SERVER_ERROR byte = 80
- Response_CLIENT_ERROR byte = 90
+ Response_OK byte = 20
+ //Response_CLIENT_TIMEOUT byte = 30
+ //Response_SERVER_TIMEOUT byte = 31
+ //Response_BAD_REQUEST byte = 40
+ //Response_BAD_RESPONSE byte = 50
+ //Response_SERVICE_NOT_FOUND byte = 60
+ //Response_SERVICE_ERROR byte = 70
+ //Response_SERVER_ERROR byte = 80
+ //Response_CLIENT_ERROR byte = 90
// According to "java dubbo" There are two cases of response:
// 1. with attachments
@@ -195,7 +195,7 @@ const (
HEADER_LENGTH = 16
// magic header
- MAGIC = uint16(0xdabb)
+ //MAGIC = uint16(0xdabb)
MAGIC_HIGH = byte(0xda)
MAGIC_LOW = byte(0xbb)
@@ -205,7 +205,6 @@ const (
FLAG_EVENT = byte(0x20) // for heartbeat
SERIAL_MASK = 0x1f
- DUBBO_VERSION = "2.5.4"
DUBBO_VERSION_KEY = "dubbo"
DEFAULT_DUBBO_PROTOCOL_VERSION = "2.0.2" // Dubbo RPC protocol version, for compatibility, it must not be between 2.0.10 ~ 2.6.2
LOWEST_VERSION_FOR_RESPONSE_ATTACHMENT = 2000200
diff --git a/protocol/dubbo/opentracing.go b/protocol/dubbo/opentracing.go
index 2dcd6a4..c1dadab 100644
--- a/protocol/dubbo/opentracing.go
+++ b/protocol/dubbo/opentracing.go
@@ -35,13 +35,13 @@ func injectTraceCtx(currentSpan opentracing.Span, inv *invocation_impl.RPCInvoca
return err
}
-func extractTraceCtx(inv *invocation_impl.RPCInvocation) (opentracing.SpanContext, error) {
- traceAttachments := filterContext(inv.Attachments())
- // actually, if user do not use any opentracing framework, the err will not be nil.
- spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,
- opentracing.TextMapCarrier(traceAttachments))
- return spanCtx, err
-}
+//func extractTraceCtx(inv *invocation_impl.RPCInvocation) (opentracing.SpanContext, error) {
+// traceAttachments := filterContext(inv.Attachments())
+// // actually, if user do not use any opentracing framework, the err will not be nil.
+// spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,
+// opentracing.TextMapCarrier(traceAttachments))
+// return spanCtx, err
+//}
func filterContext(attachments map[string]interface{}) map[string]string {
var traceAttchment = make(map[string]string)
diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go
index a9f50e8..4975dce 100644
--- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go
+++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go
@@ -32,15 +32,15 @@ import (
// It is incremented whenever an incompatibility between the generated code and
// the grpc package is introduced; the generated code references
// a constant, grpc.SupportPackageIsVersionN (where N is generatedCodeVersion).
-const generatedCodeVersion = 4
+//const generatedCodeVersion = 4
// Paths for packages used by code generated in this file,
// relative to the import_prefix of the generator.Generator.
const (
contextPkgPath = "context"
grpcPkgPath = "google.golang.org/grpc"
- codePkgPath = "google.golang.org/grpc/codes"
- statusPkgPath = "google.golang.org/grpc/status"
+ //codePkgPath = "google.golang.org/grpc/codes"
+ //statusPkgPath = "google.golang.org/grpc/status"
)
func init() {
diff --git a/protocol/jsonrpc/json.go b/protocol/jsonrpc/json.go
index 506c4c9..81ca512 100644
--- a/protocol/jsonrpc/json.go
+++ b/protocol/jsonrpc/json.go
@@ -48,13 +48,11 @@ type CodecData struct {
const (
// Errors defined in the JSON-RPC spec. See
// http://www.jsonrpc.org/specification#error_object.
- CodeParseError = -32700
- CodeInvalidRequest = -32600
- CodeMethodNotFound = -32601
- CodeInvalidParams = -32602
- CodeInternalError = -32603
- codeServerErrorStart = -32099
- codeServerErrorEnd = -32000
+ CodeParseError = -32700
+ CodeInvalidRequest = -32600
+ CodeMethodNotFound = -32601
+ CodeInvalidParams = -32602
+ CodeInternalError = -32603
)
// Error response Error
diff --git a/registry/base_configuration_listener.go b/registry/base_configuration_listener.go
index 3b36510..30d39c2 100644
--- a/registry/base_configuration_listener.go
+++ b/registry/base_configuration_listener.go
@@ -56,7 +56,7 @@ func (bcl *BaseConfigurationListener) InitWith(key string, listener config_cente
bcl.configurators = []config_center.Configurator{}
return
} else if len(rawConfig) > 0 {
- bcl.genConfiguratorFromRawRule(rawConfig)
+ _ = bcl.genConfiguratorFromRawRule(rawConfig)
}
}
diff --git a/registry/base_registry.go b/registry/base_registry.go
index a6693be..55de4bf 100644
--- a/registry/base_registry.go
+++ b/registry/base_registry.go
@@ -273,6 +273,9 @@ func (r *BaseRegistry) processURL(c *common.URL, f func(string, string) error, c
default:
return perrors.Errorf("@c{%v} type is not referencer or provider", c)
}
+ if err != nil {
+ return err
+ }
encodedURL = url.QueryEscape(rawURL)
dubboPath = strings.ReplaceAll(dubboPath, "$", "%24")
err = f(dubboPath, encodedURL)
diff --git a/registry/kubernetes/listener_test.go b/registry/kubernetes/listener_test.go
index f1d8ff4..310367b 100644
--- a/registry/kubernetes/listener_test.go
+++ b/registry/kubernetes/listener_test.go
@@ -31,137 +31,137 @@ import (
"github.com/apache/dubbo-go/remoting"
)
-var clientPodJsonData = `{
- "apiVersion": "v1",
- "kind": "Pod",
- "metadata": {
- "annotations": {
- "dubbo.io/annotation": "W3siayI6Ii9kdWJibyIsInYiOiIifSx7ImsiOiIvZHViYm8vY29tLmlrdXJlbnRvLnVzZXIuVXNlclByb3ZpZGVyIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvY29uc3VtZXJzIiwidiI6IiJ9LHsiayI6Ii9kdWJibyIsInYiOiIifSx7ImsiOiIvZHViYm8vY29tLmlrdXJlbnRvLnVzZXIuVXNlclByb3ZpZGVyIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvcHJvdmlkZXJzIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvY29uc3VtZXJzL2NvbnN1bWVyJTNB [...]
- },
- "creationTimestamp": "2020-03-13T03:38:57Z",
- "labels": {
- "dubbo.io/label": "dubbo.io-value"
- },
- "name": "client",
- "namespace": "default",
- "resourceVersion": "2449700",
- "selfLink": "/api/v1/namespaces/default/pods/client",
- "uid": "3ec394f5-dcc6-49c3-8061-57b4b2b41344"
- },
- "spec": {
- "containers": [
- {
- "env": [
- {
- "name": "NAMESPACE",
- "valueFrom": {
- "fieldRef": {
- "apiVersion": "v1",
- "fieldPath": "metadata.namespace"
- }
- }
- }
- ],
- "image": "registry.cn-hangzhou.aliyuncs.com/scottwang/dubbogo-client",
- "imagePullPolicy": "Always",
- "name": "client",
- "resources": {},
- "terminationMessagePath": "/dev/termination-log",
- "terminationMessagePolicy": "File",
- "volumeMounts": [
- {
- "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
- "name": "dubbo-sa-token-l2lzh",
- "readOnly": true
- }
- ]
- }
- ],
- "dnsPolicy": "ClusterFirst",
- "enableServiceLinks": true,
- "nodeName": "minikube",
- "priority": 0,
- "restartPolicy": "Never",
- "schedulerName": "default-scheduler",
- "securityContext": {},
- "serviceAccount": "dubbo-sa",
- "serviceAccountName": "dubbo-sa",
- "terminationGracePeriodSeconds": 30,
- "tolerations": [
- {
- "effect": "NoExecute",
- "key": "node.kubernetes.io/not-ready",
- "operator": "Exists",
- "tolerationSeconds": 300
- },
- {
- "effect": "NoExecute",
- "key": "node.kubernetes.io/unreachable",
- "operator": "Exists",
- "tolerationSeconds": 300
- }
- ],
- "volumes": [
- {
- "name": "dubbo-sa-token-l2lzh",
- "secret": {
- "defaultMode": 420,
- "secretName": "dubbo-sa-token-l2lzh"
- }
- }
- ]
- },
- "status": {
- "conditions": [
- {
- "lastProbeTime": null,
- "lastTransitionTime": "2020-03-13T03:38:57Z",
- "status": "True",
- "type": "Initialized"
- },
- {
- "lastProbeTime": null,
- "lastTransitionTime": "2020-03-13T03:40:18Z",
- "status": "True",
- "type": "Ready"
- },
- {
- "lastProbeTime": null,
- "lastTransitionTime": "2020-03-13T03:40:18Z",
- "status": "True",
- "type": "ContainersReady"
- },
- {
- "lastProbeTime": null,
- "lastTransitionTime": "2020-03-13T03:38:57Z",
- "status": "True",
- "type": "PodScheduled"
- }
- ],
- "containerStatuses": [
- {
- "containerID": "docker://2870d6abc19ca7fe22ca635ebcfac5d48c6d5550a659bafd74fb48104f6dfe3c",
- "image": "registry.cn-hangzhou.aliyuncs.com/scottwang/dubbogo-client:latest",
- "imageID": "docker-pullable://registry.cn-hangzhou.aliyuncs.com/scottwang/dubbogo-client@sha256:1f075131f708a0d400339e81549d7c4d4ed917ab0b6bd38ef458dd06ad25a559",
- "lastState": {},
- "name": "client",
- "ready": true,
- "restartCount": 0,
- "state": {
- "running": {
- "startedAt": "2020-03-13T03:40:17Z"
- }
- }
- }
- ],
- "hostIP": "10.0.2.15",
- "phase": "Running",
- "podIP": "172.17.0.8",
- "qosClass": "BestEffort",
- "startTime": "2020-03-13T03:38:57Z"
- }
-}
-`
+//var clientPodJsonData = `{
+// "apiVersion": "v1",
+// "kind": "Pod",
+// "metadata": {
+// "annotations": {
+// "dubbo.io/annotation": "W3siayI6Ii9kdWJibyIsInYiOiIifSx7ImsiOiIvZHViYm8vY29tLmlrdXJlbnRvLnVzZXIuVXNlclByb3ZpZGVyIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvY29uc3VtZXJzIiwidiI6IiJ9LHsiayI6Ii9kdWJibyIsInYiOiIifSx7ImsiOiIvZHViYm8vY29tLmlrdXJlbnRvLnVzZXIuVXNlclByb3ZpZGVyIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvcHJvdmlkZXJzIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvY29uc3VtZXJzL2NvbnN1bWVyJT [...]
+// },
+// "creationTimestamp": "2020-03-13T03:38:57Z",
+// "labels": {
+// "dubbo.io/label": "dubbo.io-value"
+// },
+// "name": "client",
+// "namespace": "default",
+// "resourceVersion": "2449700",
+// "selfLink": "/api/v1/namespaces/default/pods/client",
+// "uid": "3ec394f5-dcc6-49c3-8061-57b4b2b41344"
+// },
+// "spec": {
+// "containers": [
+// {
+// "env": [
+// {
+// "name": "NAMESPACE",
+// "valueFrom": {
+// "fieldRef": {
+// "apiVersion": "v1",
+// "fieldPath": "metadata.namespace"
+// }
+// }
+// }
+// ],
+// "image": "registry.cn-hangzhou.aliyuncs.com/scottwang/dubbogo-client",
+// "imagePullPolicy": "Always",
+// "name": "client",
+// "resources": {},
+// "terminationMessagePath": "/dev/termination-log",
+// "terminationMessagePolicy": "File",
+// "volumeMounts": [
+// {
+// "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
+// "name": "dubbo-sa-token-l2lzh",
+// "readOnly": true
+// }
+// ]
+// }
+// ],
+// "dnsPolicy": "ClusterFirst",
+// "enableServiceLinks": true,
+// "nodeName": "minikube",
+// "priority": 0,
+// "restartPolicy": "Never",
+// "schedulerName": "default-scheduler",
+// "securityContext": {},
+// "serviceAccount": "dubbo-sa",
+// "serviceAccountName": "dubbo-sa",
+// "terminationGracePeriodSeconds": 30,
+// "tolerations": [
+// {
+// "effect": "NoExecute",
+// "key": "node.kubernetes.io/not-ready",
+// "operator": "Exists",
+// "tolerationSeconds": 300
+// },
+// {
+// "effect": "NoExecute",
+// "key": "node.kubernetes.io/unreachable",
+// "operator": "Exists",
+// "tolerationSeconds": 300
+// }
+// ],
+// "volumes": [
+// {
+// "name": "dubbo-sa-token-l2lzh",
+// "secret": {
+// "defaultMode": 420,
+// "secretName": "dubbo-sa-token-l2lzh"
+// }
+// }
+// ]
+// },
+// "status": {
+// "conditions": [
+// {
+// "lastProbeTime": null,
+// "lastTransitionTime": "2020-03-13T03:38:57Z",
+// "status": "True",
+// "type": "Initialized"
+// },
+// {
+// "lastProbeTime": null,
+// "lastTransitionTime": "2020-03-13T03:40:18Z",
+// "status": "True",
+// "type": "Ready"
+// },
+// {
+// "lastProbeTime": null,
+// "lastTransitionTime": "2020-03-13T03:40:18Z",
+// "status": "True",
+// "type": "ContainersReady"
+// },
+// {
+// "lastProbeTime": null,
+// "lastTransitionTime": "2020-03-13T03:38:57Z",
+// "status": "True",
+// "type": "PodScheduled"
+// }
+// ],
+// "containerStatuses": [
+// {
+// "containerID": "docker://2870d6abc19ca7fe22ca635ebcfac5d48c6d5550a659bafd74fb48104f6dfe3c",
+// "image": "registry.cn-hangzhou.aliyuncs.com/scottwang/dubbogo-client:latest",
+// "imageID": "docker-pullable://registry.cn-hangzhou.aliyuncs.com/scottwang/dubbogo-client@sha256:1f075131f708a0d400339e81549d7c4d4ed917ab0b6bd38ef458dd06ad25a559",
+// "lastState": {},
+// "name": "client",
+// "ready": true,
+// "restartCount": 0,
+// "state": {
+// "running": {
+// "startedAt": "2020-03-13T03:40:17Z"
+// }
+// }
+// }
+// ],
+// "hostIP": "10.0.2.15",
+// "phase": "Running",
+// "podIP": "172.17.0.8",
+// "qosClass": "BestEffort",
+// "startTime": "2020-03-13T03:38:57Z"
+// }
+//}
+//`
func Test_DataChange(t *testing.T) {
listener := NewRegistryDataListener(&MockDataListener{})
diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go
index e432ca5..d5a13ec 100644
--- a/remoting/getty/getty_client.go
+++ b/remoting/getty/getty_client.go
@@ -38,8 +38,8 @@ import (
)
var (
- errInvalidCodecType = perrors.New("illegal CodecType")
- errInvalidAddress = perrors.New("remote address invalid or empty")
+ //errInvalidCodecType = perrors.New("illegal CodecType")
+ //errInvalidAddress = perrors.New("remote address invalid or empty")
errSessionNotExist = perrors.New("session not exist")
errClientClosed = perrors.New("client closed")
errClientReadTimeout = perrors.New("client read timeout")
diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go
index 0b18e97..ed64a78 100644
--- a/remoting/getty/getty_client_test.go
+++ b/remoting/getty/getty_client_test.go
@@ -87,7 +87,7 @@ func getClient(url *common.URL) *Client {
exchangeClient := remoting.NewExchangeClient(url, client, 5*time.Second, false)
client.SetExchangeClient(exchangeClient)
- client.Connect(url)
+ _ = client.Connect(url)
return client
}
@@ -109,11 +109,11 @@ func testClient_Call(t *testing.T, svr *Server, url *common.URL, c *Client) {
func testGetBigPkg(t *testing.T, c *Client) {
user := &User{}
request := remoting.NewRequest("2.0.2")
- invocation := createInvocation("GetBigPkg", nil, nil, []interface{}{[]interface{}{nil}, user},
+ ivct := createInvocation("GetBigPkg", nil, nil, []interface{}{[]interface{}{nil}, user},
[]reflect.Value{reflect.ValueOf([]interface{}{nil}), reflect.ValueOf(user)})
attachment := map[string]string{INTERFACE_KEY: "com.ikurento.user.UserProvider"}
- setAttachment(invocation, attachment)
- request.Data = invocation
+ setAttachment(ivct, attachment)
+ request.Data = ivct
request.Event = false
request.TwoWay = true
pendingResponse := remoting.NewPendingResponse(request.ID)
@@ -128,11 +128,11 @@ func testGetBigPkg(t *testing.T, c *Client) {
func testGetUser(t *testing.T, c *Client) {
user := &User{}
request := remoting.NewRequest("2.0.2")
- invocation := createInvocation("GetUser", nil, nil, []interface{}{"1", "username"},
+ ivct := createInvocation("GetUser", nil, nil, []interface{}{"1", "username"},
[]reflect.Value{reflect.ValueOf("1"), reflect.ValueOf("username")})
attachment := map[string]string{INTERFACE_KEY: "com.ikurento.user.UserProvider"}
- setAttachment(invocation, attachment)
- request.Data = invocation
+ setAttachment(ivct, attachment)
+ request.Data = ivct
request.Event = false
request.TwoWay = true
pendingResponse := remoting.NewPendingResponse(request.ID)
diff --git a/remoting/getty/opentracing.go b/remoting/getty/opentracing.go
index 7db733c..d315730 100644
--- a/remoting/getty/opentracing.go
+++ b/remoting/getty/opentracing.go
@@ -35,13 +35,13 @@ func injectTraceCtx(currentSpan opentracing.Span, inv *invocation_impl.RPCInvoca
return err
}
-func extractTraceCtx(inv *invocation_impl.RPCInvocation) (opentracing.SpanContext, error) {
- traceAttachments := filterContext(inv.Attachments())
- // actually, if user do not use any opentracing framework, the err will not be nil.
- spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,
- opentracing.TextMapCarrier(traceAttachments))
- return spanCtx, err
-}
+//func extractTraceCtx(inv *invocation_impl.RPCInvocation) (opentracing.SpanContext, error) {
+// traceAttachments := filterContext(inv.Attachments())
+// // actually, if user do not use any opentracing framework, the err will not be nil.
+// spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,
+// opentracing.TextMapCarrier(traceAttachments))
+// return spanCtx, err
+//}
func filterContext(attachments map[string]interface{}) map[string]string {
var traceAttchment = make(map[string]string)
diff --git a/remoting/getty/pool.go b/remoting/getty/pool.go
index 9689175..056d79e 100644
--- a/remoting/getty/pool.go
+++ b/remoting/getty/pool.go
@@ -149,13 +149,13 @@ func (c *gettyRPCClient) newSession(session getty.Session) error {
panic(fmt.Sprintf("%s, session.conn{%#v} is not tcp connection\n", session.Stat(), session.Conn()))
}
- tcpConn.SetNoDelay(conf.GettySessionParam.TcpNoDelay)
- tcpConn.SetKeepAlive(conf.GettySessionParam.TcpKeepAlive)
+ _ = tcpConn.SetNoDelay(conf.GettySessionParam.TcpNoDelay)
+ _ = tcpConn.SetKeepAlive(conf.GettySessionParam.TcpKeepAlive)
if conf.GettySessionParam.TcpKeepAlive {
- tcpConn.SetKeepAlivePeriod(conf.GettySessionParam.keepAlivePeriod)
+ _ = tcpConn.SetKeepAlivePeriod(conf.GettySessionParam.keepAlivePeriod)
}
- tcpConn.SetReadBuffer(conf.GettySessionParam.TcpRBufSize)
- tcpConn.SetWriteBuffer(conf.GettySessionParam.TcpWBufSize)
+ _ = tcpConn.SetReadBuffer(conf.GettySessionParam.TcpRBufSize)
+ _ = tcpConn.SetWriteBuffer(conf.GettySessionParam.TcpWBufSize)
session.SetName(conf.GettySessionParam.SessionName)
session.SetMaxMsgLen(conf.GettySessionParam.MaxMsgLen)
diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go
index 61d13ef..5e5f167 100644
--- a/remoting/nacos/builder_test.go
+++ b/remoting/nacos/builder_test.go
@@ -31,19 +31,19 @@ import (
func TestNewNacosClient(t *testing.T) {
rc := &config.RemoteConfig{}
- client, err := NewNacosClient(rc)
+ _, err := NewNacosClient(rc)
// address is nil
assert.NotNil(t, err)
rc.Address = "console.nacos.io:80:123"
- client, err = NewNacosClient(rc)
+ _, err = NewNacosClient(rc)
// invalid address
assert.NotNil(t, err)
rc.Address = "console.nacos.io:80"
rc.TimeoutStr = "10s"
- client, err = NewNacosClient(rc)
+ client, err := NewNacosClient(rc)
assert.NotNil(t, client)
assert.Nil(t, err)
}
diff --git a/remoting/zookeeper/client_test.go b/remoting/zookeeper/client_test.go
index 3474170..c033ff9 100644
--- a/remoting/zookeeper/client_test.go
+++ b/remoting/zookeeper/client_test.go
@@ -81,7 +81,9 @@ func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.
func Test_newMockZookeeperClient(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
- defer ts.Stop()
+ defer func() {
+ _ = ts.Stop()
+ }()
states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
verifyEventStateOrder(t, event, states, "event channel")
@@ -92,7 +94,9 @@ func Test_newMockZookeeperClient(t *testing.T) {
func TestCreate(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
- defer ts.Stop()
+ defer func() {
+ _ = ts.Stop()
+ }()
err = z.Create("test1/test2/test3/test4")
assert.NoError(t, err)
@@ -103,7 +107,9 @@ func TestCreate(t *testing.T) {
func TestCreateDelete(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
- defer ts.Stop()
+ defer func() {
+ _ = ts.Stop()
+ }()
states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
verifyEventStateOrder(t, event, states, "event channel")
@@ -117,7 +123,10 @@ func TestCreateDelete(t *testing.T) {
func TestRegisterTemp(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
- defer ts.Stop()
+ defer func() {
+ _ = ts.Stop()
+ }()
+
err = z.Create("/test1/test2/test3")
assert.NoError(t, err)
@@ -131,7 +140,10 @@ func TestRegisterTemp(t *testing.T) {
func TestRegisterTempSeq(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
- defer ts.Stop()
+ defer func() {
+ _ = ts.Stop()
+ }()
+
err = z.Create("/test1/test2/test3")
assert.NoError(t, err)
tmpath, err := z.RegisterTempSeq("/test1/test2/test3", []byte("test"))