diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go
index 644f67c5244350897bbc3e291e66e2421758fce5..12799994125c4bf5d968dfc811cda374effbf85c 100644
--- a/cluster/cluster_impl/base_cluster_invoker.go
+++ b/cluster/cluster_impl/base_cluster_invoker.go
@@ -45,6 +45,7 @@ func newBaseClusterInvoker(directory cluster.Directory) baseClusterInvoker {
destroyed: atomic.NewBool(false),
}
}
+
func (invoker *baseClusterInvoker) GetUrl() common.URL {
return invoker.directory.GetUrl()
}
diff --git a/cluster/cluster_impl/base_cluster_invoker_test.go b/cluster/cluster_impl/base_cluster_invoker_test.go
index 49df78c41b3c3cc7dacf92153fc7e4515a0caec0..d074697b85a3cf5b770de90da4847043d98c9df1 100644
--- a/cluster/cluster_impl/base_cluster_invoker_test.go
+++ b/cluster/cluster_impl/base_cluster_invoker_test.go
@@ -47,6 +47,7 @@ func Test_StickyNormal(t *testing.T) {
result1 := base.doSelect(loadbalance.NewRandomLoadBalance(), invocation.NewRPCInvocation("getUser", nil, nil), invokers, invoked)
assert.Equal(t, result, result1)
}
+
func Test_StickyNormalWhenError(t *testing.T) {
invokers := []protocol.Invoker{}
for i := 0; i < 10; i++ {
diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go
index 99c584bb583c1d59ece505feafd74ad6e11f6b9a..1be21067a6a9045cb6ae6f84655d516fea1f844b 100644
--- a/cluster/cluster_impl/failover_cluster_test.go
+++ b/cluster/cluster_impl/failover_cluster_test.go
@@ -118,6 +118,7 @@ func normalInvoke(t *testing.T, successCount int, urlParam url.Values, invocatio
}
return clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{})
}
+
func Test_FailoverInvokeSuccess(t *testing.T) {
urlParams := url.Values{}
result := normalInvoke(t, 3, urlParams)
diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go
index 9d3f3f882156e1df61eac1adca67dec450964396..6765a810a5ed48d95f49b5b97fbf660dd8587715 100644
--- a/common/proxy/proxy.go
+++ b/common/proxy/proxy.go
@@ -59,6 +59,7 @@ func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[str
// type XxxProvider struct {
// Yyy func(ctx context.Context, args []interface{}, rsp *Zzz) error
// }
+
func (p *Proxy) Implement(v common.RPCService) {
// check parameters, incoming interface must be a elem's pointer.
diff --git a/common/url.go b/common/url.go
index 7ede3d94fb321d0f5364f408327f591774f25652..ebb648db27c3efff534f0d0a545f2211f335aa89 100644
--- a/common/url.go
+++ b/common/url.go
@@ -277,6 +277,7 @@ func (c URL) URLEqual(url URL) bool {
}
return true
}
+
func isMatchCategory(category1 string, category2 string) bool {
if len(category2) == 0 {
return category1 == constant.DEFAULT_CATEGORY
@@ -288,6 +289,7 @@ func isMatchCategory(category1 string, category2 string) bool {
return strings.Contains(category2, category1)
}
}
+
func (c URL) String() string {
var buildString string
if len(c.Username) == 0 && len(c.Password) == 0 {
diff --git a/common/url_test.go b/common/url_test.go
index 835973065b6d7426e5487fe76602ca27701130a1..2372de520e88b0949023e88cec64871736dd6aa0 100644
--- a/common/url_test.go
+++ b/common/url_test.go
@@ -164,6 +164,7 @@ func TestURL_GetParamAndDecoded(t *testing.T) {
v, _ := u.GetParamAndDecoded("rule")
assert.Equal(t, rule, v)
}
+
func TestURL_GetRawParam(t *testing.T) {
u, _ := NewURL("condition://0.0.0.0:8080/com.foo.BarService?serialization=fastjson")
u.Username = "test"
@@ -176,6 +177,7 @@ func TestURL_GetRawParam(t *testing.T) {
assert.Equal(t, "/com.foo.BarService", u.GetRawParam("path"))
assert.Equal(t, "fastjson", u.GetRawParam("serialization"))
}
+
func TestURL_ToMap(t *testing.T) {
u, _ := NewURL("condition://0.0.0.0:8080/com.foo.BarService?serialization=fastjson")
u.Username = "test"
diff --git a/config/base_config.go b/config/base_config.go
index a52dc756e78d6488b52fe6365e7830378e094740..909b6bc8f48f51528de93aa67ac788f05a8c18b2 100644
--- a/config/base_config.go
+++ b/config/base_config.go
@@ -140,6 +140,7 @@ func getKeyPrefix(val reflect.Value) []string {
return retPrefixs
}
+
func getPtrElement(v reflect.Value) reflect.Value {
if v.Kind() == reflect.Ptr {
v = v.Elem()
@@ -149,6 +150,7 @@ func getPtrElement(v reflect.Value) reflect.Value {
}
return v
}
+
func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryConfiguration) {
for i := 0; i < val.NumField(); i++ {
if key := val.Type().Field(i).Tag.Get("property"); key != "-" && key != "" {
@@ -302,6 +304,7 @@ func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryC
}
}
}
+
func (c *BaseConfig) fresh() {
configList := config.GetEnvInstance().Configuration()
for element := configList.Front(); element != nil; element = element.Next() {
diff --git a/config/protocol_config.go b/config/protocol_config.go
index 4828d6e5bd28de19d896340f39c5633d0acd4874..33de976bc6f5bf7341ddcff8d51c505cf23bbccd 100644
--- a/config/protocol_config.go
+++ b/config/protocol_config.go
@@ -38,14 +38,13 @@ func (c *ProtocolConfig) Prefix() string {
}
func loadProtocol(protocolsIds string, protocols map[string]*ProtocolConfig) []*ProtocolConfig {
- returnProtocols := []*ProtocolConfig{}
+ returnProtocols := make([]*ProtocolConfig, 0, len(protocols))
for _, v := range strings.Split(protocolsIds, ",") {
- for k, prot := range protocols {
+ for k, protocol := range protocols {
if v == k {
- returnProtocols = append(returnProtocols, prot)
+ returnProtocols = append(returnProtocols, protocol)
}
}
-
}
return returnProtocols
}
diff --git a/config/reference_config.go b/config/reference_config.go
index edfa17a27e88a605b71bc7f6dec1b133bd29abe9..7ce0013194f5c1a1d09e014a858433833aa07f0e 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -77,7 +77,6 @@ func NewReferenceConfig(id string, ctx context.Context) *ReferenceConfig {
// UnmarshalYAML ...
func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
-
type rf ReferenceConfig
raw := rf{} // Put your defaults here
if err := unmarshal(&raw); err != nil {
@@ -101,8 +100,8 @@ func (c *ReferenceConfig) Refer(_ interface{}) {
common.WithParamsValue(constant.BEAN_NAME_KEY, c.id),
)
- //1. user specified URL, could be peer-to-peer address, or register center's address.
if c.Url != "" {
+ // 1. user specified URL, could be peer-to-peer address, or register center's address.
urlStrings := gxstrings.RegSplit(c.Url, "\\s*[;]+\\s*")
for _, urlStr := range urlStrings {
serviceUrl, err := common.NewURL(urlStr)
@@ -120,21 +119,21 @@ func (c *ReferenceConfig) Refer(_ interface{}) {
newUrl := common.MergeUrl(&serviceUrl, cfgURL)
c.urls = append(c.urls, newUrl)
}
-
}
} else {
- //2. assemble SubURL from register center's configuration模式
+ // 2. assemble SubURL from register center's configuration mode
c.urls = loadRegistries(c.Registry, consumerConfig.Registries, common.CONSUMER)
- //set url to regUrls
+ // set url to regUrls
for _, regUrl := range c.urls {
regUrl.SubURL = cfgURL
}
}
+
if len(c.urls) == 1 {
c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(*c.urls[0])
} else {
- invokers := []protocol.Invoker{}
+ invokers := make([]protocol.Invoker, 0, len(c.urls))
var regUrl *common.URL
for _, u := range c.urls {
invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(*u))
@@ -151,7 +150,7 @@ func (c *ReferenceConfig) Refer(_ interface{}) {
}
}
- //create proxy
+ // create proxy
if c.Async {
callback := GetCallback(c.id)
c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL)
@@ -219,7 +218,6 @@ func (c *ReferenceConfig) getUrlMap() url.Values {
}
return urlMap
-
}
// GenericLoad ...
diff --git a/config/registry_config_test.go b/config/registry_config_test.go
index 45d38b29cc7089dabc5d7b7e34390ee48a58dc97..6c2fed605d6c50b483f7ad2900e5a483b3986e1b 100644
--- a/config/registry_config_test.go
+++ b/config/registry_config_test.go
@@ -46,6 +46,7 @@ func Test_loadRegistries(t *testing.T) {
fmt.Println(urls[0])
assert.Equal(t, "127.0.0.2:2181,128.0.0.1:2181", urls[0].Location)
}
+
func Test_loadRegistries1(t *testing.T) {
target := "shanghai1"
regs := map[string]*RegistryConfig{
diff --git a/config/service_config.go b/config/service_config.go
index 2111838395d507ebac4f72883c99dd2bb1615850..7d97fa4d1e95bd79e051f77deaeafa1afcc58b0f 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -96,14 +96,12 @@ func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
// NewServiceConfig The only way to get a new ServiceConfig
func NewServiceConfig(id string, context context.Context) *ServiceConfig {
-
return &ServiceConfig{
context: context,
id: id,
unexported: atomic.NewBool(false),
exported: atomic.NewBool(false),
}
-
}
// Export ...
@@ -171,10 +169,8 @@ func (c *ServiceConfig) Export() error {
panic(perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error,url is {%v}", ivkURL)))
}
}
-
}
return nil
-
}
// Implement ...
@@ -242,5 +238,4 @@ func (c *ServiceConfig) getUrlMap() url.Values {
}
return urlMap
-
}
diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go
index 85dff14a1ec9ba3905890bf37dc1e1827d59d80f..4dc19817846fe5c9c0552738f2058a15d20efabc 100644
--- a/config_center/apollo/impl.go
+++ b/config_center/apollo/impl.go
@@ -163,6 +163,7 @@ func (c *apolloConfiguration) getAddressWithProtocolPrefix(url *common.URL) stri
func (c *apolloConfiguration) Parser() parser.ConfigurationParser {
return c.parser
}
+
func (c *apolloConfiguration) SetParser(p parser.ConfigurationParser) {
c.parser = p
}
diff --git a/config_center/configurator/override.go b/config_center/configurator/override.go
index d0b23ef2f20d065135547536c2cebcec3eec0ce1..18415bee3a28b37ffc2f3f73cc7309b685de5408 100644
--- a/config_center/configurator/override.go
+++ b/config_center/configurator/override.go
@@ -36,6 +36,7 @@ import (
func init() {
extension.SetDefaultConfigurator(newConfigurator)
}
+
func newConfigurator(url *common.URL) config_center.Configurator {
return &overrideConfigurator{configuratorUrl: url}
}
diff --git a/config_center/configurator/override_test.go b/config_center/configurator/override_test.go
index 329c598efe8ef79d7fc1b79ae182c59b238283ac..c0aeb15130e7862fcb00d6cb82cbef60df777acb 100644
--- a/config_center/configurator/override_test.go
+++ b/config_center/configurator/override_test.go
@@ -40,8 +40,8 @@ func Test_configureVerison2p6(t *testing.T) {
assert.NoError(t, err)
configurator.Configure(&providerUrl)
assert.Equal(t, "failfast", providerUrl.GetParam(constant.CLUSTER_KEY, ""))
-
}
+
func Test_configureVerisonOverrideAddr(t *testing.T) {
url, err := common.NewURL("override://0.0.0.0:0/com.xxx.mock.userProvider?group=1&version=1&cluster=failfast&application=BDTService&providerAddresses=127.0.0.2:20001|127.0.0.3:20001")
assert.NoError(t, err)
@@ -52,8 +52,8 @@ func Test_configureVerisonOverrideAddr(t *testing.T) {
assert.NoError(t, err)
configurator.Configure(&providerUrl)
assert.Equal(t, "failover", providerUrl.GetParam(constant.CLUSTER_KEY, ""))
-
}
+
func Test_configureVerison2p6WithIp(t *testing.T) {
url, err := common.NewURL("override://127.0.0.1:20001/com.xxx.mock.userProvider?group=1&version=1&cluster=failfast&application=BDTService")
assert.NoError(t, err)
diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go
index 58fcdb49dad2c53270894a65bf4ebd9595dc420e..f342dc62e765f8d38c9e64ba3be03f3362f0bf61 100644
--- a/config_center/parser/configuration_parser.go
+++ b/config_center/parser/configuration_parser.go
@@ -109,6 +109,7 @@ func (parser *DefaultConfigurationParser) ParseToUrls(content string) ([]*common
}
return allUrls, nil
}
+
func serviceItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
var addresses = item.Addresses
if len(addresses) == 0 {
@@ -154,6 +155,7 @@ func serviceItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.UR
}
return urls, nil
}
+
func appItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
var addresses = item.Addresses
if len(addresses) == 0 {
@@ -246,6 +248,7 @@ func getParamString(item ConfigItem) (string, error) {
return retStr, nil
}
+
func getEnabledString(item ConfigItem, config ConfiguratorConfig) string {
retStr := "&enabled="
if len(item.Type) == 0 || item.Type == GeneralType {
diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index 70fb196a1eedb994eae38576de35d36deb450aaa..404243d4751146d1edc9a61d51cbb81d73c2ffb1 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -155,6 +155,7 @@ func (c *zookeeperDynamicConfiguration) GetRule(key string, opts ...config_cente
func (c *zookeeperDynamicConfiguration) Parser() parser.ConfigurationParser {
return c.parser
}
+
func (c *zookeeperDynamicConfiguration) SetParser(p parser.ConfigurationParser) {
c.parser = p
}
diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go
index 1d62f3df86f5706823cab7c9ed0bc1a7d9b380f3..22e15193cba1b533a2b1b965a44bf9665a6a4e5e 100644
--- a/config_center/zookeeper/impl_test.go
+++ b/config_center/zookeeper/impl_test.go
@@ -77,6 +77,7 @@ func initZkData(group string, t *testing.T) (*zk.TestCluster, *zookeeperDynamicC
return ts, reg
}
+
func Test_GetConfig(t *testing.T) {
ts, reg := initZkData("dubbo", t)
defer ts.Stop()
diff --git a/filter/filter_impl/auth/consumer_sign.go b/filter/filter_impl/auth/consumer_sign.go
index 4280a491970d869a4063bafd2d5be49c63f05a5c..062744771acf8ccd505265875a103d24afeb06af 100644
--- a/filter/filter_impl/auth/consumer_sign.go
+++ b/filter/filter_impl/auth/consumer_sign.go
@@ -55,6 +55,7 @@ func (csf *ConsumerSignFilter) Invoke(ctx context.Context, invoker protocol.Invo
func (csf *ConsumerSignFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
return result
}
+
func getConsumerSignFilter() filter.Filter {
return &ConsumerSignFilter{}
}
diff --git a/filter/filter_impl/auth/provider_auth.go b/filter/filter_impl/auth/provider_auth.go
index fc88e29471fa9e0a937b1474aa6a704aab9f24fd..0d5772e5508894111a88443bfe2d1b02ebfac54a 100644
--- a/filter/filter_impl/auth/provider_auth.go
+++ b/filter/filter_impl/auth/provider_auth.go
@@ -58,6 +58,7 @@ func (paf *ProviderAuthFilter) Invoke(ctx context.Context, invoker protocol.Invo
func (paf *ProviderAuthFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
return result
}
+
func getProviderAuthFilter() filter.Filter {
return &ProviderAuthFilter{}
}
diff --git a/filter/filter_impl/generic_filter.go b/filter/filter_impl/generic_filter.go
index e8ff2679b0294d6519aecd1cc1fe37bdeab89e46..9bc131ef8903942b84df2b8fc14fd11143d1a7b6 100644
--- a/filter/filter_impl/generic_filter.go
+++ b/filter/filter_impl/generic_filter.go
@@ -83,6 +83,7 @@ func (ef *GenericFilter) OnResponse(_ context.Context, result protocol.Result, _
func GetGenericFilter() filter.Filter {
return &GenericFilter{}
}
+
func struct2MapAll(obj interface{}) interface{} {
if obj == nil {
return obj
@@ -127,6 +128,7 @@ func struct2MapAll(obj interface{}) interface{} {
return obj
}
}
+
func setInMap(m map[string]interface{}, structField reflect.StructField, value interface{}) (result map[string]interface{}) {
result = m
if tagName := structField.Tag.Get("m"); tagName == "" {
@@ -136,6 +138,7 @@ func setInMap(m map[string]interface{}, structField reflect.StructField, value i
}
return
}
+
func headerAtoa(a string) (b string) {
b = strings.ToLower(a[:1]) + a[1:]
return
diff --git a/filter/filter_impl/generic_filter_test.go b/filter/filter_impl/generic_filter_test.go
index 22948353fc16a99696a85489ce5df7dc9b18a7ba..b08229199898a30657682d47c32689dc084f5bf4 100644
--- a/filter/filter_impl/generic_filter_test.go
+++ b/filter/filter_impl/generic_filter_test.go
@@ -88,6 +88,7 @@ func Test_struct2MapAll_Slice(t *testing.T) {
assert.Equal(t, reflect.Slice, reflect.TypeOf(m["caCa"]).Kind())
assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"].([]interface{})[0].(map[string]interface{})["xxYy"]).Kind())
}
+
func Test_struct2MapAll_Map(t *testing.T) {
var testData struct {
AaAa string
diff --git a/filter/filter_impl/hystrix_filter_test.go b/filter/filter_impl/hystrix_filter_test.go
index 66c17d920c14e23f1562773c152e99955a48bfb9..71fc097c8bf4752e0cb2b451b0da7e16480b0701 100644
--- a/filter/filter_impl/hystrix_filter_test.go
+++ b/filter/filter_impl/hystrix_filter_test.go
@@ -213,6 +213,7 @@ func TestGetHystrixFilterConsumer(t *testing.T) {
assert.NotNil(t, get)
assert.True(t, get.(*HystrixFilter).COrP)
}
+
func TestGetHystrixFilterProvider(t *testing.T) {
get := GetHystrixFilterProvider()
assert.NotNil(t, get)
diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go
index 5c5304463be72e061fa100324f2c050f8ab0ec82..0dde44e73c18f65f262e01f499e198995907dece 100644
--- a/registry/directory/directory_test.go
+++ b/registry/directory/directory_test.go
@@ -45,6 +45,7 @@ import (
func init() {
config.SetConsumerConfig(config.ConsumerConfig{ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}})
}
+
func TestSubscribe(t *testing.T) {
registryDirectory, _ := normalRegistryDir()
@@ -123,6 +124,7 @@ func Test_List(t *testing.T) {
assert.Equal(t, true, registryDirectory.IsAvailable())
}
+
func Test_MergeProviderUrl(t *testing.T) {
registryDirectory, mockRegistry := normalRegistryDir(true)
providerUrl, _ := common.NewURL("dubbo://0.0.0.0:20000/org.apache.dubbo-go.mockService",
diff --git a/registry/etcdv3/listener.go b/registry/etcdv3/listener.go
index 79e3ad514584937e742db4bbc993202dd6a9f5b9..f9b046a2c52814cd4e5ea38f9ea4c58c8bdb5bc4 100644
--- a/registry/etcdv3/listener.go
+++ b/registry/etcdv3/listener.go
@@ -83,6 +83,7 @@ func NewConfigurationListener(reg *etcdV3Registry) *configurationListener {
reg.WaitGroup().Add(1)
return &configurationListener{registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32)}
}
+
func (l *configurationListener) Process(configType *config_center.ConfigChangeEvent) {
l.events <- configType
}
@@ -108,6 +109,7 @@ func (l *configurationListener) Next() (*registry.ServiceEvent, error) {
}
}
}
+
func (l *configurationListener) Close() {
l.registry.WaitGroup().Done()
}
diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go
index 748b8204d97e60c9803821290184fc5717c41025..a7678ba4e2f38cfeb77f202103e03066a7efdbef 100644
--- a/registry/protocol/protocol.go
+++ b/registry/protocol/protocol.go
@@ -77,6 +77,7 @@ func newRegistryProtocol() *registryProtocol {
bounds: &sync.Map{},
}
}
+
func getRegistry(regUrl *common.URL) registry.Registry {
reg, err := extension.GetRegistry(regUrl.Protocol, regUrl)
if err != nil {
@@ -85,13 +86,14 @@ func getRegistry(regUrl *common.URL) registry.Registry {
}
return reg
}
+
func (proto *registryProtocol) initConfigurationListeners() {
proto.overrideListeners = &sync.Map{}
proto.serviceConfigurationListeners = &sync.Map{}
proto.providerConfigurationListener = newProviderConfigurationListener(proto.overrideListeners)
}
-func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
+func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
var registryUrl = url
var serviceUrl = registryUrl.SubURL
if registryUrl.Protocol == constant.REGISTRY_PROTOCOL {
@@ -115,6 +117,7 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
serviceUrl.String(), err.Error())
return nil
}
+
err = reg.Register(*serviceUrl)
if err != nil {
logger.Errorf("consumer service %v register registry %v error, error message is %s",
@@ -131,7 +134,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
}
func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
-
proto.once.Do(func() {
proto.initConfigurationListeners()
})
@@ -172,13 +174,14 @@ func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporte
wrappedInvoker := newWrappedInvoker(invoker, providerUrl)
cachedExporter = extension.GetProtocol(protocolwrapper.FILTER).Export(wrappedInvoker)
proto.bounds.Store(key, cachedExporter)
- logger.Infof("The exporter has not been cached, and will return a new exporter!")
+ logger.Infof("The exporter has not been cached, and will return a new exporter!")
}
go reg.Subscribe(overriderUrl, overrideSubscribeListener)
return cachedExporter.(protocol.Exporter)
}
+
func (proto *registryProtocol) reExport(invoker protocol.Invoker, newUrl *common.URL) {
url := getProviderUrl(invoker)
key := getCacheKey(url)
@@ -202,12 +205,14 @@ type overrideSubscribeListener struct {
func newOverrideSubscribeListener(overriderUrl *common.URL, invoker protocol.Invoker, proto *registryProtocol) *overrideSubscribeListener {
return &overrideSubscribeListener{url: overriderUrl, originInvoker: invoker, protocol: proto}
}
+
func (nl *overrideSubscribeListener) Notify(event *registry.ServiceEvent) {
if isMatched(&(event.Service), nl.url) && event.Action == remoting.EventTypeAdd {
nl.configurator = extension.GetDefaultConfigurator(&(event.Service))
nl.doOverrideIfNecessary()
}
}
+
func (nl *overrideSubscribeListener) doOverrideIfNecessary() {
providerUrl := getProviderUrl(nl.originInvoker)
key := getCacheKey(providerUrl)
@@ -276,6 +281,7 @@ func isMatched(providerUrl *common.URL, consumerUrl *common.URL) bool {
consumerVersion == providerVersion) && (len(consumerClassifier) == 0 ||
consumerClassifier == constant.ANY_VALUE || consumerClassifier == providerClassifier)
}
+
func isMatchCategory(category string, categories string) bool {
if len(categories) == 0 {
return category == constant.DEFAULT_CATEGORY
@@ -287,6 +293,7 @@ func isMatchCategory(category string, categories string) bool {
return strings.Contains(categories, category)
}
}
+
func getSubscribedOverrideUrl(providerUrl *common.URL) *common.URL {
newUrl := providerUrl.Clone()
newUrl.Protocol = constant.PROVIDER_PROTOCOL
@@ -334,6 +341,7 @@ func getProviderUrl(invoker protocol.Invoker) *common.URL {
//be careful params maps in url is map type
return url.SubURL.Clone()
}
+
func setProviderUrl(regURL *common.URL, providerURL *common.URL) {
regURL.SubURL = providerURL
}
diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go
index de57a0afa7529dd5c77c1fe5440b336cdd212fca..cee2a6a625368f655d1b9bc5fe8cc37031e1aef7 100644
--- a/registry/protocol/protocol_test.go
+++ b/registry/protocol/protocol_test.go
@@ -44,6 +44,7 @@ import (
func init() {
config.SetProviderConfig(config.ProviderConfig{ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}})
}
+
func referNormal(t *testing.T, regProtocol *registryProtocol) {
extension.SetProtocol("registry", GetProtocol)
extension.SetRegistry("mock", registry.NewMockRegistry)
diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go
index f4e53dcc4219d947fea93a10bccc420811afd2b9..e13443d57d7dae9fb5d50b2e1c28f618780fd850 100644
--- a/registry/zookeeper/registry.go
+++ b/registry/zookeeper/registry.go
@@ -141,6 +141,7 @@ func (r *zkRegistry) CloseAndNilClient() {
r.client.Close()
r.client = nil
}
+
func (r *zkRegistry) ZkClient() *zookeeper.ZookeeperClient {
return r.client
}
diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go
index 97ea775652cf82ce86388fb376832ccb7e07a205..a41f6cd3230700332519ce1c2d3489bfcc4b6ef0 100644
--- a/remoting/zookeeper/facade_test.go
+++ b/remoting/zookeeper/facade_test.go
@@ -70,6 +70,7 @@ func (r *mockFacade) Destroy() {
func (r *mockFacade) RestartCallBack() bool {
return true
}
+
func (r *mockFacade) IsAvailable() bool {
return true
}
diff --git a/remoting/zookeeper/listener_test.go b/remoting/zookeeper/listener_test.go
index 43e9aca3f44470873c3c97ec2447bebcc57e5545..7301cd52c392b6950b3a49f78e8124eae532b083 100644
--- a/remoting/zookeeper/listener_test.go
+++ b/remoting/zookeeper/listener_test.go
@@ -66,6 +66,7 @@ func initZkData(t *testing.T) (*zk.TestCluster, *ZookeeperClient, <-chan zk.Even
return ts, client, event
}
+
func TestListener(t *testing.T) {
changedData := `
dubbo.consumer.request_timeout=3s