From 2e1e4745fcf201b096bb17f38a823d21dff95c1a Mon Sep 17 00:00:00 2001 From: cjp <cjp_ca@163.com> Date: Fri, 1 Jan 2021 19:17:27 +0800 Subject: [PATCH] delete unused variable --- cluster/router/tag/tag_router_test.go | 1 - config_center/nacos/client.go | 4 - protocol/dubbo/hessian2/const.go | 9 -- protocol/dubbo/impl/const.go | 9 -- protocol/dubbo/opentracing.go | 8 -- .../protoc-gen-dubbo/plugin/dubbo/dubbo.go | 8 -- protocol/jsonrpc/json.go | 2 - registry/kubernetes/listener_test.go | 132 ------------------ remoting/getty/getty_client.go | 2 - remoting/getty/opentracing.go | 8 -- 10 files changed, 183 deletions(-) diff --git a/cluster/router/tag/tag_router_test.go b/cluster/router/tag/tag_router_test.go index 3f7b979f3..d27e64441 100644 --- a/cluster/router/tag/tag_router_test.go +++ b/cluster/router/tag/tag_router_test.go @@ -74,7 +74,6 @@ const ( var ( zkFormat = "zookeeper://%s:%d" - conditionFormat = "condition://%s/com.foo.BarService" ) // MockInvoker is only mock the Invoker to support test tagRouter diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go index f3942c023..c7d631c76 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" @@ -38,9 +37,6 @@ import ( "github.com/apache/dubbo-go/common/logger" ) -// Nacos Log dir, it can be override when creating client by config_center.log_dir -var logDir = filepath.Join("logs", "nacos", "log") - // NacosClient Nacos client type NacosClient struct { name string diff --git a/protocol/dubbo/hessian2/const.go b/protocol/dubbo/hessian2/const.go index 74a00b601..0c95390fb 100644 --- a/protocol/dubbo/hessian2/const.go +++ b/protocol/dubbo/hessian2/const.go @@ -28,11 +28,6 @@ import ( perrors "github.com/pkg/errors" ) -const ( - mask = byte(127) - flag = byte(128) -) - const ( // Zero : byte zero Zero = byte(0x00) @@ -84,10 +79,6 @@ const ( 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/impl/const.go b/protocol/dubbo/impl/const.go index 70d8bae6c..492a87a19 100644 --- a/protocol/dubbo/impl/const.go +++ b/protocol/dubbo/impl/const.go @@ -28,11 +28,6 @@ const ( DUBBO = "dubbo" ) -const ( - mask = byte(127) - flag = byte(128) -) - const ( // Zero : byte zero Zero = byte(0x00) @@ -84,10 +79,6 @@ const ( 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/opentracing.go b/protocol/dubbo/opentracing.go index 2dcd6a4d0..f45e6fdc7 100644 --- a/protocol/dubbo/opentracing.go +++ b/protocol/dubbo/opentracing.go @@ -35,14 +35,6 @@ 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 filterContext(attachments map[string]interface{}) map[string]string { var traceAttchment = make(map[string]string) for k, v := range attachments { diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go index 11e9b2115..78847282d 100644 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go +++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go @@ -28,19 +28,11 @@ import ( "github.com/golang/protobuf/protoc-gen-go/generator" ) -// generatedCodeVersion indicates a version of the generated code. -// 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 - // 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" ) func init() { diff --git a/protocol/jsonrpc/json.go b/protocol/jsonrpc/json.go index 506c4c953..57d36d2ea 100644 --- a/protocol/jsonrpc/json.go +++ b/protocol/jsonrpc/json.go @@ -53,8 +53,6 @@ const ( CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 - codeServerErrorStart = -32099 - codeServerErrorEnd = -32000 ) // Error response Error diff --git a/registry/kubernetes/listener_test.go b/registry/kubernetes/listener_test.go index f1d8ff417..ef6e8fb1f 100644 --- a/registry/kubernetes/listener_test.go +++ b/registry/kubernetes/listener_test.go @@ -31,138 +31,6 @@ import ( "github.com/apache/dubbo-go/remoting" ) -var clientPodJsonData = `{ - "apiVersion": "v1", - "kind": "Pod", - "metadata": { - "annotations": { - "dubbo.io/annotation": "W3siayI6Ii9kdWJibyIsInYiOiIifSx7ImsiOiIvZHViYm8vY29tLmlrdXJlbnRvLnVzZXIuVXNlclByb3ZpZGVyIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvY29uc3VtZXJzIiwidiI6IiJ9LHsiayI6Ii9kdWJibyIsInYiOiIifSx7ImsiOiIvZHViYm8vY29tLmlrdXJlbnRvLnVzZXIuVXNlclByb3ZpZGVyIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvcHJvdmlkZXJzIiwidiI6IiJ9LHsiayI6Ii9kdWJiby9jb20uaWt1cmVudG8udXNlci5Vc2VyUHJvdmlkZXIvY29uc3VtZXJzL2NvbnN1bWVyJTNBJTJGJTJGMTcyLjE3LjAuOCUyRlVzZXJQcm92aWRlciUzRmNhdGVnb3J5JTNEY29uc3VtZXJzJTI2ZHViYm8lM0RkdWJib2dvLWNvbnN1bWVyLTIuNi4wJTI2cHJvdG9jb2wlM0RkdWJibyIsInYiOiIifV0=" - }, - "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{}) url, _ := common.NewURL("jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-2.6.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100") diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 17b523191..da31c0bf4 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -38,8 +38,6 @@ import ( ) var ( - 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/opentracing.go b/remoting/getty/opentracing.go index 7db733cbe..4ba4fde9d 100644 --- a/remoting/getty/opentracing.go +++ b/remoting/getty/opentracing.go @@ -35,14 +35,6 @@ 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 filterContext(attachments map[string]interface{}) map[string]string { var traceAttchment = make(map[string]string) for k, v := range attachments { -- GitLab