Skip to content
Snippets Groups Projects
Commit ca718628 authored by AlexStocks's avatar AlexStocks
Browse files

delete unused var

parent 2acf10ac
No related branches found
No related tags found
No related merge requests found
Showing
with 58 additions and 47 deletions
......@@ -77,8 +77,7 @@ func (invoker *failbackClusterInvoker) tryTimerTaskProc(ctx context.Context, ret
invoked = append(invoked, retryTask.lastInvoker)
retryInvoker := invoker.doSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked)
var result protocol.Result
result = retryInvoker.Invoke(ctx, retryTask.invocation)
result := retryInvoker.Invoke(ctx, retryTask.invocation)
if result.Error() != nil {
retryTask.lastInvoker = retryInvoker
invoker.checkRetry(retryTask, result.Error())
......
......@@ -195,7 +195,7 @@ func (c *RouterChain) copyInvokerIfNecessary(cache *InvokerCache) []protocol.Inv
func (c *RouterChain) buildCache() {
origin := c.loadCache()
invokers := c.copyInvokerIfNecessary(origin)
if invokers == nil || len(invokers) == 0 {
if len(invokers) == 0 {
return
}
......
......@@ -238,6 +238,7 @@ conditions:
func TestRouterChainRouteNoRoute(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.Nil(t, err)
defer func() {
err := ts.Stop()
assert.NoError(t, err)
......@@ -247,6 +248,7 @@ func TestRouterChainRouteNoRoute(t *testing.T) {
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
assert.Nil(t, err)
chain, err := NewRouterChain(getConditionNoRouteUrl(applicationKey))
assert.Nil(t, err)
......
......@@ -47,8 +47,8 @@ type listenableRouter struct {
conditionRouters []*ConditionRouter
routerRule *RouterRule
url *common.URL
force bool
priority int64
//force bool
priority int64
}
// RouterRule Get RouterRule instance from listenableRouter
......
......@@ -41,7 +41,7 @@ type FileTagRouter struct {
router *tagRouter
routerRule *RouterRule
url *common.URL
force bool
//force bool
}
// NewFileTagRouter Create file tag router instance with content (from config file)
......
......@@ -84,9 +84,9 @@ func (t *RouterRule) getTagNames() []string {
return result
}
func (t *RouterRule) hasTag(tag string) bool {
return len(t.TagNameToAddresses[tag]) > 0
}
//func (t *RouterRule) hasTag(tag string) bool {
// return len(t.TagNameToAddresses[tag]) > 0
//}
func (t *RouterRule) getAddressToTagNames() map[string][]string {
return t.AddressToTagNames
......@@ -96,10 +96,10 @@ func (t *RouterRule) getTagNameToAddresses() map[string][]string {
return t.TagNameToAddresses
}
func (t *RouterRule) getTags() []Tag {
return t.Tags
}
//func (t *RouterRule) getTags() []Tag {
// return t.Tags
//}
func (t *RouterRule) setTags(tags []Tag) {
t.Tags = tags
}
//func (t *RouterRule) setTags(tags []Tag) {
// t.Tags = tags
//}
......@@ -53,7 +53,7 @@ type addrMetadata struct {
// application name
application string
// is rule a runtime rule
ruleRuntime bool
//ruleRuntime bool
// is rule a force rule
ruleForce bool
// is rule a valid rule
......@@ -227,7 +227,7 @@ func (c *tagRouter) Pool(invokers []protocol.Invoker) (router.AddrPool, router.A
// fetchRuleIfNecessary fetches, parses rule and register listener for the further change
func (c *tagRouter) fetchRuleIfNecessary(invokers []protocol.Invoker) {
if invokers == nil || len(invokers) == 0 {
if len(invokers) == 0 {
return
}
......
......@@ -237,7 +237,7 @@ func TestRouteBeijingInvoker(t *testing.T) {
type DynamicTagRouter struct {
suite.Suite
rule *RouterRule
//rule *RouterRule
route *tagRouter
zkClient *zookeeper.ZookeeperClient
......
......@@ -34,8 +34,8 @@ import (
// We just have config center configuration which can override configuration in consumer.yaml & provider.yaml.
// But for add these features in future ,I finish the environment struct following Environment class in java.
type Environment struct {
configCenterFirst bool
externalConfigs sync.Map
configCenterFirst bool
//externalConfigs sync.Map
externalConfigMap sync.Map
appExternalConfigMap sync.Map
dynamicConfiguration config_center.DynamicConfiguration
......
......@@ -17,6 +17,8 @@
package constant
type DubboCtxKey string
const (
ASYNC_KEY = "async" // it's value should be "true" or "false" of string type
)
......@@ -47,8 +49,8 @@ const (
PORT_KEY = "port"
PROTOCOL_KEY = "protocol"
PATH_SEPARATOR = "/"
DUBBO_KEY = "dubbo"
SSL_ENABLED_KEY = "ssl-enabled"
//DUBBO_KEY = "dubbo"
SSL_ENABLED_KEY = "ssl-enabled"
)
const (
......@@ -92,7 +94,7 @@ const (
)
const (
DUBBOGO_CTX_KEY = "dubbogo-ctx"
DUBBOGO_CTX_KEY = DubboCtxKey("dubbogo-ctx")
)
const (
......@@ -201,8 +203,6 @@ const (
TRACING_REMOTE_SPAN_CTX = "tracing.remote.span.ctx"
)
type AttachmentCtxKey string
// Use for router module
const (
// ConditionRouterName Specify file condition router name
......@@ -240,7 +240,7 @@ const (
Tagkey = "dubbo.tag"
// Attachment key in context in invoker
AttachmentKey = AttachmentCtxKey("attachment")
AttachmentKey = DubboCtxKey("attachment")
)
const (
......
......@@ -27,6 +27,10 @@ import (
"github.com/stretchr/testify/assert"
)
import (
"github.com/apache/dubbo-go/common/constant"
)
const (
referenceTestPath = "com.test.Path"
referenceTestPathDistinct = "com.test.Path1"
......@@ -125,7 +129,7 @@ func TestServiceMapUnRegister(t *testing.T) {
err = ServiceMap.UnRegister("", testProtocol, ServiceKey("TestService", "", "v0"))
assert.EqualError(t, err, "no service for TestService:v0")
// succ
// success
err = ServiceMap.UnRegister("TestService", testProtocol, ServiceKey("TestService", "", "v1"))
assert.NoError(t, err)
}
......@@ -133,16 +137,12 @@ func TestServiceMapUnRegister(t *testing.T) {
func TestMethodTypeSuiteContext(t *testing.T) {
mt := &MethodType{ctxType: reflect.TypeOf(context.TODO())}
ctx := context.Background()
type ctxKey string
key := ctxKey("key")
key := constant.DubboCtxKey("key")
ctx = context.WithValue(ctx, key, "value")
assert.Equal(t, reflect.ValueOf(ctx), mt.SuiteContext(ctx))
assert.Equal(t, reflect.Zero(mt.ctxType), mt.SuiteContext(nil))
}
func TestSuiteMethod(t *testing.T) {
s := &TestService{}
method, ok := reflect.TypeOf(s).MethodByName("MethodOne")
assert.True(t, ok)
......
......@@ -415,6 +415,9 @@ func (c *URL) Service() string {
func (c *URL) AddParam(key string, value string) {
c.paramsLock.Lock()
defer c.paramsLock.Unlock()
if c.params == nil {
c.params = url.Values{}
}
c.params.Add(key, value)
}
......@@ -433,6 +436,9 @@ func (c *URL) AddParamAvoidNil(key string, value string) {
func (c *URL) SetParam(key string, value string) {
c.paramsLock.Lock()
defer c.paramsLock.Unlock()
if c.params == nil {
c.params = url.Values{}
}
c.params.Set(key, value)
}
......@@ -440,7 +446,9 @@ func (c *URL) SetParam(key string, value string) {
func (c *URL) DelParam(key string) {
c.paramsLock.Lock()
defer c.paramsLock.Unlock()
c.params.Del(key)
if c.params != nil {
c.params.Del(key)
}
}
// ReplaceParams will replace the URL.params
......@@ -466,10 +474,15 @@ func (c *URL) RangeParams(f func(key, value string) bool) {
func (c *URL) GetParam(s string, d string) string {
c.paramsLock.RLock()
defer c.paramsLock.RUnlock()
r := c.params.Get(s)
var r string
if len(c.params) > 0 {
r = c.params.Get(s)
}
if len(r) == 0 {
r = d
}
return r
}
......
......@@ -70,9 +70,8 @@ func TestURL(t *testing.T) {
urlInst := URL{}
urlInst.noCopy.Lock()
urlInst.SetParam("hello", "world")
urlInst.noCopy.Unlock()
urlInst.baseUrl.paramsLock.Lock()
urlInst.baseUrl.paramsLock.Unlock()
assert.Equal(t, "/com.ikurento.user.UserProvider", u.Path)
assert.Equal(t, "127.0.0.1:20000", u.Location)
......
......@@ -45,7 +45,7 @@ type BaseConfig struct {
// application config
ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`
prefix string
//prefix string
fatherConfig interface{}
EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"`
MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"`
......
......@@ -107,6 +107,7 @@ var baseMockRef = map[string]*ReferenceConfig{
func TestRefresh(t *testing.T) {
c := &BaseConfig{}
c.fileStream = nil
mockMap := getMockMap()
mockMap["dubbo.shutdown.timeout"] = "12s"
......
......@@ -18,10 +18,8 @@
package config
import (
"context"
"net/url"
"reflect"
"time"
)
import (
......@@ -46,7 +44,7 @@ import (
//
// ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo
type ConfigCenterConfig struct {
context context.Context
//context context.Context
Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
Address string `yaml:"address" json:"address,omitempty"`
Cluster string `yaml:"cluster" json:"cluster,omitempty"`
......@@ -60,7 +58,7 @@ type ConfigCenterConfig struct {
AppId string `default:"dubbo" yaml:"app_id" json:"app_id,omitempty"`
TimeoutStr string `yaml:"timeout" json:"timeout,omitempty"`
RemoteRef string `required:"false" yaml:"remote_ref" json:"remote_ref,omitempty"`
timeout time.Duration
//timeout time.Duration
}
// UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function
......
......@@ -406,9 +406,9 @@ func GetBaseConfig() *BaseConfig {
baseConfig = &BaseConfig{
MetricConfig: &MetricConfig{},
ConfigCenterConfig: &ConfigCenterConfig{},
Remotes: make(map[string]*RemoteConfig, 0),
Remotes: make(map[string]*RemoteConfig),
ApplicationConfig: &ApplicationConfig{},
ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig, 0),
ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig),
}
}
}
......
......@@ -146,8 +146,7 @@ func (c *apolloConfiguration) getAddressWithProtocolPrefix(url *common.URL) stri
address := url.Location
converted := address
if len(address) != 0 {
reg := regexp.MustCompile("\\s+")
address = reg.ReplaceAllString(address, "")
address := regexp.MustCompile(`\s+`).ReplaceAllString(address, "")
parts := strings.Split(address, ",")
addrs := make([]string, 0)
for _, part := range parts {
......
......@@ -143,7 +143,7 @@ func serviceConfigResponse(rw http.ResponseWriter, _ *http.Request) {
// run mock config server
func runMockConfigServer(handlerMap map[string]func(http.ResponseWriter, *http.Request),
notifyHandler func(http.ResponseWriter, *http.Request)) *httptest.Server {
uriHandlerMap := make(map[string]func(http.ResponseWriter, *http.Request), 0)
uriHandlerMap := make(map[string]func(http.ResponseWriter, *http.Request))
for namespace, handler := range handlerMap {
uri := fmt.Sprintf("/configs/%s/%s/%s", mockAppId, mockCluster, namespace)
uriHandlerMap[uri] = handler
......
......@@ -65,7 +65,7 @@ type option func(*options)
type options struct {
nacosName string
client *NacosClient
//client *NacosClient
}
// WithNacosName Set nacos name
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment