You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/04/24 14:07:29 UTC

[GitHub] [dubbo-go] lzp0412 opened a new pull request #491: Feature/dubbo 2.7.5

lzp0412 opened a new pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491


   #420 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...658c0b9](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...41615c3](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r432919595



##########
File path: remoting/nacos/builder.go
##########
@@ -21,16 +21,81 @@ import (
 	"net"
 	"strconv"
 	"strings"
+	"time"
 
+	"github.com/apache/dubbo-go/config"
+)
+
+import (
 	"github.com/nacos-group/nacos-sdk-go/clients"
+	"github.com/nacos-group/nacos-sdk-go/clients/config_client"
 	"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
 	nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant"
 	perrors "github.com/pkg/errors"
+)
 
+import (
+	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
-	"github.com/apache/dubbo-go/config"
 )
 
+func NewNacosNamingClient(url *common.URL) (naming_client.INamingClient, error) {
+	nacosConfig, err := getNacosConfig(url)
+	if err != nil {
+		return nil, err
+	}
+	return clients.CreateNamingClient(nacosConfig)
+}
+
+func NewNacosConfigClient(url *common.URL) (config_client.IConfigClient, error) {
+	nacosConfig, err := getNacosConfig(url)
+	if err != nil {
+		return nil, err
+	}
+	return clients.CreateConfigClient(nacosConfig)
+}
+
+// getNacosConfig will return the nacos config
+func getNacosConfig(url *common.URL) (map[string]interface{}, error) {
+	if url == nil {
+		return nil, perrors.New("url is empty!")
+	}
+	if len(url.Location) == 0 {
+		return nil, perrors.New("url.location is empty!")
+	}
+	configMap := make(map[string]interface{}, 2)
+
+	addresses := strings.Split(url.Location, ",")
+	serverConfigs := make([]nacosConstant.ServerConfig, 0, len(addresses))
+	for _, addr := range addresses {
+		ip, portStr, err := net.SplitHostPort(addr)
+		if err != nil {
+			return nil, perrors.WithMessagef(err, "split [%s] ", addr)
+		}
+		port, _ := strconv.Atoi(portStr)
+		serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{
+			IpAddr: ip,
+			Port:   uint64(port),
+		})
+	}
+	configMap["serverConfigs"] = serverConfigs
+
+	var clientConfig nacosConstant.ClientConfig
+	timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT))
+	if err != nil {
+		return nil, err
+	}
+	clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000)

Review comment:
       pls init the config in a struct.
   
   ```Go
      clientConfig := nacosConstant.ClientConfig {
          xxx: xxx,
      }




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zouyx commented on a change in pull request #491: ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r419834256



##########
File path: config/base_config.go
##########
@@ -279,7 +295,7 @@ func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryC
 
 					}
 
-					//iter := f.MapRange()
+					// iter := f.MapRange()

Review comment:
       delete it?

##########
File path: config/base_config.go
##########
@@ -63,7 +79,7 @@ func (c *BaseConfig) startConfigCenter() error {
 	if c.prepareEnvironment() != nil {
 		return perrors.WithMessagef(err, "start config center error!")
 	}
-	//c.fresh()
+	// c.fresh()

Review comment:
       delete it?

##########
File path: config/router_config_test.go
##########
@@ -53,15 +52,3 @@ func TestString(t *testing.T) {
 	assert.Equal(t, n2[0], "a1")
 	assert.Equal(t, n2[1], "")
 }
-
-func TestRouterInit(t *testing.T) {

Review comment:
       why delete this case?

##########
File path: registry/nacos/registry.go
##########
@@ -19,9 +19,14 @@ package nacos
 
 import (
 	"bytes"
+	"net"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/nacos-group/nacos-sdk-go/clients"
+	"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
+	nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant"

Review comment:
       split

##########
File path: registry/nacos/service_discovery_test.go
##########
@@ -18,25 +18,31 @@
 package nacos
 
 import (
-	"strconv"
 	"testing"
+	"time"
+
+	"github.com/apache/dubbo-go/config"

Review comment:
       as above

##########
File path: config/remote_config_test.go
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package config
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"

Review comment:
       split

##########
File path: registry/nacos/service_discovery.go
##########
@@ -18,15 +18,21 @@
 package nacos
 
 import (
+	"fmt"
+	"sync"
+
 	"github.com/dubbogo/gost/container/set"
 	"github.com/dubbogo/gost/page"
+	"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
 	"github.com/nacos-group/nacos-sdk-go/model"
 	"github.com/nacos-group/nacos-sdk-go/vo"
 	perrors "github.com/pkg/errors"
+
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/remoting/nacos"

Review comment:
       split 

##########
File path: registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rest

Review comment:
       add some comment for those public methods in this file




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r432919378



##########
File path: metadata/report/nacos/report.go
##########
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package nacos
+
+import (
+	"encoding/json"
+	"net/url"
+)
+
+import (
+	"github.com/nacos-group/nacos-sdk-go/clients/config_client"
+	"github.com/nacos-group/nacos-sdk-go/vo"
+	perrors "github.com/pkg/errors"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/identifier"
+	"github.com/apache/dubbo-go/metadata/report"
+	"github.com/apache/dubbo-go/metadata/report/factory"
+	"github.com/apache/dubbo-go/remoting/nacos"
+)
+
+func init() {
+	ftry := &nacosMetadataReportFactory{}
+	extension.SetMetadataReportFactory("nacos", func() factory.MetadataReportFactory {
+		return ftry
+	})
+}
+
+// nacosMetadataReport is the implementation of MetadataReport based Nacos
+type nacosMetadataReport struct {
+	client config_client.IConfigClient
+}
+
+// StoreProviderMetadata will store the metadata
+func (n *nacosMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error {
+	return n.storeMetadata(vo.ConfigParam{
+		DataId:  providerIdentifier.GetIdentifierKey(),
+		Group:   providerIdentifier.Group,
+		Content: serviceDefinitions,
+	})
+}
+
+// StoreConsumerMetadata will store the metadata

Review comment:
       store the consumer metadata.

##########
File path: metadata/report/nacos/report.go
##########
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package nacos
+
+import (
+	"encoding/json"
+	"net/url"
+)
+
+import (
+	"github.com/nacos-group/nacos-sdk-go/clients/config_client"
+	"github.com/nacos-group/nacos-sdk-go/vo"
+	perrors "github.com/pkg/errors"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/identifier"
+	"github.com/apache/dubbo-go/metadata/report"
+	"github.com/apache/dubbo-go/metadata/report/factory"
+	"github.com/apache/dubbo-go/remoting/nacos"
+)
+
+func init() {
+	ftry := &nacosMetadataReportFactory{}
+	extension.SetMetadataReportFactory("nacos", func() factory.MetadataReportFactory {
+		return ftry
+	})
+}
+
+// nacosMetadataReport is the implementation of MetadataReport based Nacos
+type nacosMetadataReport struct {
+	client config_client.IConfigClient
+}
+
+// StoreProviderMetadata will store the metadata

Review comment:
       store the provider metadata

##########
File path: metadata/report/nacos/report.go
##########
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package nacos
+
+import (
+	"encoding/json"
+	"net/url"
+)
+
+import (
+	"github.com/nacos-group/nacos-sdk-go/clients/config_client"
+	"github.com/nacos-group/nacos-sdk-go/vo"
+	perrors "github.com/pkg/errors"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/identifier"
+	"github.com/apache/dubbo-go/metadata/report"
+	"github.com/apache/dubbo-go/metadata/report/factory"
+	"github.com/apache/dubbo-go/remoting/nacos"
+)
+
+func init() {
+	ftry := &nacosMetadataReportFactory{}
+	extension.SetMetadataReportFactory("nacos", func() factory.MetadataReportFactory {
+		return ftry
+	})
+}
+
+// nacosMetadataReport is the implementation of MetadataReport based Nacos
+type nacosMetadataReport struct {
+	client config_client.IConfigClient
+}
+
+// StoreProviderMetadata will store the metadata
+func (n *nacosMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error {
+	return n.storeMetadata(vo.ConfigParam{
+		DataId:  providerIdentifier.GetIdentifierKey(),
+		Group:   providerIdentifier.Group,
+		Content: serviceDefinitions,
+	})
+}
+
+// StoreConsumerMetadata will store the metadata
+func (n *nacosMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error {
+	return n.storeMetadata(vo.ConfigParam{
+		DataId:  consumerMetadataIdentifier.GetIdentifierKey(),
+		Group:   consumerMetadataIdentifier.Group,
+		Content: serviceParameterString,
+	})
+}
+
+// SaveServiceMetadata will store the metadata

Review comment:
       save the service metadata.

##########
File path: metadata/report/nacos/report.go
##########
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package nacos
+
+import (
+	"encoding/json"
+	"net/url"
+)
+
+import (
+	"github.com/nacos-group/nacos-sdk-go/clients/config_client"
+	"github.com/nacos-group/nacos-sdk-go/vo"
+	perrors "github.com/pkg/errors"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/identifier"
+	"github.com/apache/dubbo-go/metadata/report"
+	"github.com/apache/dubbo-go/metadata/report/factory"
+	"github.com/apache/dubbo-go/remoting/nacos"
+)
+
+func init() {
+	ftry := &nacosMetadataReportFactory{}
+	extension.SetMetadataReportFactory("nacos", func() factory.MetadataReportFactory {
+		return ftry
+	})
+}
+
+// nacosMetadataReport is the implementation of MetadataReport based Nacos
+type nacosMetadataReport struct {
+	client config_client.IConfigClient
+}
+
+// StoreProviderMetadata will store the metadata
+func (n *nacosMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error {
+	return n.storeMetadata(vo.ConfigParam{
+		DataId:  providerIdentifier.GetIdentifierKey(),
+		Group:   providerIdentifier.Group,
+		Content: serviceDefinitions,
+	})
+}
+
+// StoreConsumerMetadata will store the metadata
+func (n *nacosMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error {
+	return n.storeMetadata(vo.ConfigParam{
+		DataId:  consumerMetadataIdentifier.GetIdentifierKey(),
+		Group:   consumerMetadataIdentifier.Group,
+		Content: serviceParameterString,
+	})
+}
+
+// SaveServiceMetadata will store the metadata
+func (n *nacosMetadataReport) SaveServiceMetadata(metadataIdentifier *identifier.ServiceMetadataIdentifier, url common.URL) error {
+	return n.storeMetadata(vo.ConfigParam{
+		DataId:  metadataIdentifier.GetIdentifierKey(),
+		Group:   metadataIdentifier.Group,
+		Content: url.String(),
+	})
+}
+
+// RemoveServiceMetadata will remove the service metadata
+func (n *nacosMetadataReport) RemoveServiceMetadata(metadataIdentifier *identifier.ServiceMetadataIdentifier) error {
+	return n.deleteMetadata(vo.ConfigParam{
+		DataId: metadataIdentifier.GetIdentifierKey(),
+		Group:  metadataIdentifier.Group,
+	})
+}
+
+// GetExportedURLs will look up the exported urls.
+// if not found, an empty list will be returned.
+func (n *nacosMetadataReport) GetExportedURLs(metadataIdentifier *identifier.ServiceMetadataIdentifier) []string {
+	return n.getConfigAsArray(vo.ConfigParam{
+		DataId: metadataIdentifier.GetIdentifierKey(),
+		Group:  metadataIdentifier.Group,
+	})
+}
+
+// SaveSubscribedData will convert the urlList to json array and then store it
+func (n *nacosMetadataReport) SaveSubscribedData(subscriberMetadataIdentifier *identifier.SubscriberMetadataIdentifier, urlList []common.URL) error {
+	if len(urlList) == 0 {
+		logger.Warnf("The url list is empty")
+		return nil
+	}
+	urlStrList := make([]string, 0, len(urlList))
+
+	for _, e := range urlList {
+		urlStrList = append(urlStrList, e.String())
+	}
+
+	bytes, err := json.Marshal(urlStrList)
+

Review comment:
       delete this blank line.

##########
File path: metadata/report/nacos/report_test.go
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package nacos
+
+import (

Review comment:
       split.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re:[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #491: ServiceDiscoveryRegistry implementation

Posted by Brooks <br...@chtrak.com>.
如何退订












If you have great talents, industry will improve them; if you have but moderate abilities, industry will supply their deficiency
If you have further question, please don't hesitate to contact us again.
Have a nice day :)


Best regards,
Brooks






----------------------------------------------------------------- 
This message may contain confidential information. If you are
not the intended recipient and have received this message, please
notify the sender and delete it from the system immediately.
Disclosing, duplicating this message or taking action based on it,
is strictly prohibited. 
-----------------------------------------------------------------









在2020年04月29 10时29分,"GitBox"<gi...@apache.org>写道:

AlexStocks commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r417033848



##########
File path: go.mod
##########
@@ -23,6 +23,7 @@ require (
 	github.com/golang/mock v1.3.1
 	github.com/golang/protobuf v1.3.2
 	github.com/google/btree v1.0.0 // indirect
+	github.com/gotestyourself/gotestyourself v2.2.0+incompatible

Review comment:
       why import this useless package?

##########
File path: common/extension/service_instance_selector_factory.go
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package extension
+
+import (
+	"github.com/apache/dubbo-go/registry/service/instance"

Review comment:
       pls do not place the dubbo-go package and the third package in the same import block.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #491: ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r417033848



##########
File path: go.mod
##########
@@ -23,6 +23,7 @@ require (
 	github.com/golang/mock v1.3.1
 	github.com/golang/protobuf v1.3.2
 	github.com/google/btree v1.0.0 // indirect
+	github.com/gotestyourself/gotestyourself v2.2.0+incompatible

Review comment:
       why import this useless package?

##########
File path: common/extension/service_instance_selector_factory.go
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package extension
+
+import (
+	"github.com/apache/dubbo-go/registry/service/instance"

Review comment:
       pls do not place the dubbo-go package and the third package in the same import block.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [dubbo-go] codecov-commenter commented on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `1.52%`.
   > The diff coverage is `22.44%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   64.53%   -1.53%     
   =======================================================
     Files                      203      202       -1     
     Lines                    10558    10596      +38     
   =======================================================
   - Hits                      6975     6838     -137     
   - Misses                    2909     3103     +194     
   + Partials                   674      655      -19     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.57% <0.57%> (ø)` | |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `69.23% <40.00%> (-19.01%)` | :arrow_down: |
   | ... and [40 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...7e912e7](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zouyx commented on a change in pull request #491: ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r419110336



##########
File path: config/config_loader.go
##########
@@ -104,6 +104,8 @@ func loadConsumerConfig() {
 	applicationConfig = consumerConfig.ApplicationConfig
 	extension.SetAndInitGlobalDispatcher(consumerConfig.eventDispatcherType)
 
+	extension.SetAndInitGlobalDispatcher(consumerConfig.eventDispatcherType)

Review comment:
       the same to line 105?

##########
File path: config/config_loader.go
##########
@@ -181,6 +183,8 @@ func loadProviderConfig() {
 	applicationConfig = providerConfig.ApplicationConfig
 	extension.SetAndInitGlobalDispatcher(providerConfig.eventDispatcherType)
 
+	extension.SetAndInitGlobalDispatcher(consumerConfig.eventDispatcherType)

Review comment:
       the same to line 184?

##########
File path: registry/servicediscovery/proxy/metadata_service_proxy_factory.go
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package proxy
+
+var (
+	serviceProxy = make(map[string]func() BaseMetadataServiceProxy)
+)
+
+func SetMetadataServiceProxy(name string, creator func() BaseMetadataServiceProxy) {
+	//TODO
+}
+
+func GetMetadataServiceProxy(name string) BaseMetadataServiceProxy {
+	//TODO
+	return nil
+}

Review comment:
       should implement?

##########
File path: registry/event_listener.go
##########
@@ -25,20 +25,34 @@ import (
 	"github.com/apache/dubbo-go/common/observer"
 )
 
-// TODO (implement ConditionalEventListener)
+//The Service Discovery Changed  Event Listener
 type ServiceInstancesChangedListener struct {
 	ServiceName string
-	observer.EventListener
+	observer.ConditionalEventListener
+	ChangedNotify ChangedNotify
 }
 
-func (sicl *ServiceInstancesChangedListener) OnEvent(e observer.Event) error {
+//On ServiceInstancesChangedEvent the service instances change event
+func (sicl *ServiceInstancesChangedListener) OnEvent(e ServiceInstancesChangedEvent) error {
+	sicl.ChangedNotify.Notify(e)
 	return nil
 }
 
+//get listener priority
 func (sicl *ServiceInstancesChangedListener) GetPriority() int {
 	return -1
 }
 
+//get event type
 func (sicl *ServiceInstancesChangedListener) GetEventType() reflect.Type {
 	return reflect.TypeOf(&ServiceInstancesChangedEvent{})
 }
+
+//If service name matches,return true or false
+func (sicl *ServiceInstancesChangedListener) Accept(e ServiceInstancesChangedEvent) bool {
+	return e.ServiceName == sicl.ServiceName
+}
+
+type ChangedNotify interface {

Review comment:
       should it move to parent package?

##########
File path: registry/servicediscovery/service_discovery_registry.go
##########
@@ -0,0 +1,596 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package servicediscovery
+
+import (
+	"bytes"
+	"encoding/json"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+import (
+	cm "github.com/Workiva/go-datastructures/common"
+	gxset "github.com/dubbogo/gost/container/set"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/servicediscovery/proxy"
+	"github.com/apache/dubbo-go/registry/servicediscovery/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+)
+
+const (
+	protocolName = "service-discovery"
+)
+
+func init() {
+	extension.SetRegistry(protocolName, newServiceDiscoveryRegistry)
+}
+
+// serviceDiscoveryRegistry is the implementation of application-level registry.
+// It's completely different from other registry implementations
+// This implementation is based on ServiceDiscovery abstraction and ServiceNameMapping
+// In order to keep compatible with interface-level registry,
+// 1. when we registry the service, we should create the mapping from service name to application name
+// 2. when we sub
+type serviceDiscoveryRegistry struct {
+	lock               sync.RWMutex
+	url                *common.URL
+	serviceDiscovery   registry.ServiceDiscovery
+	subscribedServices *gxset.HashSet
+	serviceNameMapping mapping.ServiceNameMapping
+	metaDataService    service.MetadataService
+	//cache the registered listen
+	registeredListeners *gxset.HashSet
+	//all synthesize
+	subscribedURLsSynthesizers []synthesizer.SubscribedURLsSynthesizer
+	//cache exported  urls,   serviceName->revision->[]URL
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+//GetServiceDiscovery for get serviceDiscovery of the registry
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+//GetUrl for get url of the registry
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+//IsAvailable for make sure is't available
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true

Review comment:
       always true?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...bfb89b5](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...e2da137](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...7e912e7](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...34775e5](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-636299314


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/9578fc0bbc1bbabfa6afc79bad3b5fd89009af3b&el=desc) will **decrease** coverage by `2.42%`.
   > The diff coverage is `30.89%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.06%   63.63%   -2.43%     
   =======================================================
     Files                      203      210       +7     
     Lines                    10558    11163     +605     
   =======================================================
   + Hits                      6975     7104     +129     
   - Misses                    2909     3371     +462     
   - Partials                   674      688      +14     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cluster/directory/base\_directory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y2x1c3Rlci9kaXJlY3RvcnkvYmFzZV9kaXJlY3RvcnkuZ28=) | `72.50% <ø> (+6.59%)` | :arrow_up: |
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [config/consumer\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL2NvbnN1bWVyX2NvbmZpZy5nbw==) | `56.25% <ø> (ø)` | |
   | [config/provider\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3Byb3ZpZGVyX2NvbmZpZy5nbw==) | `55.88% <ø> (ø)` | |
   | [config/reference\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JlZmVyZW5jZV9jb25maWcuZ28=) | `78.70% <ø> (ø)` | |
   | [config/router\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnL3JvdXRlcl9jb25maWcuZ28=) | `0.00% <0.00%> (-85.72%)` | :arrow_down: |
   | [metadata/mapping/dynamic/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-bWV0YWRhdGEvbWFwcGluZy9keW5hbWljL3NlcnZpY2VfbmFtZV9tYXBwaW5nLmdv) | `61.90% <0.00%> (-26.34%)` | :arrow_down: |
   | [...try/servicediscovery/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZWRpc2NvdmVyeS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.56% <0.56%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [9578fc0...7019888](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #491: ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r419057071



##########
File path: config/service_config.go
##########
@@ -113,6 +113,24 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig {
 	}
 }
 
+// Get Random Port
+func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List {

Review comment:
       this work has been done by Mr Zouyx. why u do it again?

##########
File path: config/config_loader.go
##########
@@ -211,19 +194,10 @@ func loadProviderConfig() {
 			logger.Warnf("%s does not exist!", key)
 			continue
 		}
-		checkRegistries(providerConfig.Registries, providerConfig.Registry)
-		for key, svs := range providerConfig.Services {
-			rpcService := GetProviderService(key)
-			if rpcService == nil {
-				logger.Warnf("%s does not exist!", key)
-				continue
-			}
-			svs.id = key
-			svs.Implement(rpcService)
-			svs.Protocols = providerConfig.Protocols
-			if err := svs.Export(); err != nil {
-				panic(fmt.Sprintf("service %s export failed! err: %#v", key, err))
-			}
+		svs.id = key
+		svs.Implement(rpcService)
+		if err := svs.Export(); err != nil {
+			panic(fmt.Sprintf("service %s export failed! err: %#v", key, err))

Review comment:
       hi, new guy, pls use %+v for error to handle nil-error or self-defined error.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zouyx commented on a change in pull request #491: ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#discussion_r417720915



##########
File path: common/extension/service_name_mapping.go
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package extension
+
+import (
+	"github.com/apache/dubbo-go/metadata/mapping"
+)
+
+var (
+	nameMappings = make(map[string]func() mapping.ServiceNameMapping)
+)
+
+func SetServiceNameMapping(name string, creator func() mapping.ServiceNameMapping) {
+	// TODO(@邓大明)

Review comment:
       use english pls

##########
File path: common/extension/service_discovery.go
##########
@@ -18,11 +18,11 @@
 package extension
 
 import (
+	"github.com/apache/dubbo-go/registry"

Review comment:
       format 

##########
File path: common/extension/service_name_mapping.go
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package extension
+
+import (
+	"github.com/apache/dubbo-go/metadata/mapping"
+)
+
+var (
+	nameMappings = make(map[string]func() mapping.ServiceNameMapping)
+)
+
+func SetServiceNameMapping(name string, creator func() mapping.ServiceNameMapping) {
+	// TODO(@邓大明)
+}
+
+func GetServiceNameMapping(name string) mapping.ServiceNameMapping {
+	// TODO(@邓大明)

Review comment:
       as above

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {

Review comment:
       ```suggestion
   		if len(s) > 0 {
   ```

##########
File path: registry/service/instance/random/random_service_instance_selector.go
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package random
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/instance"
+	"math/rand"
+	"time"

Review comment:
       split those package

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true

Review comment:
       always true?

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"

Review comment:
       format those package

##########
File path: registry/service/instance/random/random_service_instance_selector_test.go
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package random
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/stretchr/testify/assert"
+	"testing"

Review comment:
       format  those package

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true
+}
+
+func (s *serviceDiscoveryRegistry) Destroy() {
+	err := s.serviceDiscovery.Destroy()
+	if err != nil {
+		logger.Errorf("destroy serviceDiscovery catch error:%s", err.Error())
+	}
+}
+
+func (s *serviceDiscoveryRegistry) Register(url common.URL) error {
+	if !shouldRegister(url) {
+		return nil
+	}
+	ok, err := s.metaDataService.ExportURL(url)
+	if err != nil {
+		logger.Errorf("The URL[%s] registry catch error:%s!", url.String(), err.Error())
+		return err
+	}
+	if ok {
+		logger.Infof("The URL[%s] registry successfully!", url.String())
+	} else {
+		logger.Warnf("The URL[%s] has been registry!", url.String())
+	}
+	return nil
+}
+
+func shouldRegister(url common.URL) bool {
+	side := url.GetParam(constant.SIDE_KEY, "")
+	if side == constant.PROVIDER_PROTOCOL {
+		return true
+	}
+	logger.Debugf("The URL should not be register.", url.String())
+	return false
+}
+
+func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.NotifyListener) {
+	if !shouldSubscribe(*url) {
+		return
+	}
+	_, err := s.metaDataService.SubscribeURL(*url)
+	if err != nil {
+		logger.Errorf("subscribe url[%s] catch error:%s", url.String(), err.Error())
+		return
+	}
+	services := s.getServices(*url)
+	if services.Empty() {
+		logger.Errorf("Should has at least one way to know which services this interface belongs to, "+
+			"subscription url:%s", url.String())
+		return
+	}
+	for _, srv := range services.Values() {
+		serviceName := srv.(string)
+		serviceInstances := s.serviceDiscovery.GetInstances(serviceName)
+		s.subscribe(url, notify, serviceName, serviceInstances)
+		listener := &registry.ServiceInstancesChangedListener{
+			ServiceName: serviceName,
+			ChangedNotify: &InstanceChangeNotify{
+				notify:                   notify,
+				serviceDiscoveryRegistry: s,
+			},
+		}
+		s.registerServiceInstancesChangedListener(*url, listener)
+	}
+
+}
+func (s *serviceDiscoveryRegistry) registerServiceInstancesChangedListener(url common.URL, listener *registry.ServiceInstancesChangedListener) {
+	listenerId := listener.ServiceName + ":" + getUrlKey(url)
+	if !s.subscribedServices.Contains(listenerId) {
+		err := s.serviceDiscovery.AddListener(listener)
+		if err != nil {
+			logger.Errorf("add listener[%s] catch error,url:%s err:%s", listenerId, url.String(), err.Error())
+		}
+	}
+
+}
+
+func getUrlKey(url common.URL) string {
+	var bf bytes.Buffer
+	if len(url.Protocol) != 0 {
+		bf.WriteString(url.Protocol)
+		bf.WriteString("://")
+	}
+	if len(url.Location) != 0 {
+		bf.WriteString(url.Location)
+		bf.WriteString(":")
+		bf.WriteString(url.Port)
+	}
+	if len(url.Path) != 0 {
+		bf.WriteString("/")
+		bf.WriteString(url.Path)
+	}
+	bf.WriteString("?")
+	appendParam(bf, constant.VERSION_KEY, url)
+	appendParam(bf, constant.GROUP_KEY, url)
+	appendParam(bf, constant.NACOS_PROTOCOL_KEY, url)
+	return bf.String()
+}
+
+func appendParam(buffer bytes.Buffer, paramKey string, url common.URL) {
+	buffer.WriteString(paramKey)
+	buffer.WriteString("=")
+	buffer.WriteString(url.GetParam(paramKey, ""))
+}
+
+func (s *serviceDiscoveryRegistry) subscribe(url *common.URL, notify registry.NotifyListener,
+	serviceName string, serviceInstances []registry.ServiceInstance) {
+	if len(serviceInstances) == 0 {
+		logger.Warnf("here is no instance in service[name : %s]", serviceName)
+		return
+	}
+	var subscribedURLs []common.URL
+	subscribedURLs = append(subscribedURLs, s.getExportedUrls(*url, serviceInstances)...)
+	if len(subscribedURLs) == 0 {
+		subscribedURLs = s.synthesizeSubscribedURLs(url, serviceInstances)
+	}
+	//TODO make sure it's workable
+	for _, url := range subscribedURLs {
+		notify.Notify(&registry.ServiceEvent{
+			Action:  remoting.EventTypeAdd,
+			Service: url,
+		})
+	}
+
+}
+
+func (s *serviceDiscoveryRegistry) synthesizeSubscribedURLs(subscribedURL *common.URL, serviceInstances []registry.ServiceInstance) []common.URL {
+	var urls []common.URL
+	for _, syn := range s.subscribedURLsSynthesizers {
+		if syn.Support(subscribedURL) {
+			urls = append(urls, syn.Synthesize(subscribedURL, serviceInstances)...)
+		}
+	}
+	return urls
+}
+func shouldSubscribe(url common.URL) bool {
+	return !shouldRegister(url)
+}
+
+func (s *serviceDiscoveryRegistry) getServices(url common.URL) *gxset.HashSet {
+	services := gxset.NewSet()
+	serviceNames := url.GetParam(constant.PROVIDER_BY, "")
+	if len(serviceNames) != 0 {
+		services = parseServices(serviceNames)
+	}
+	if services.Empty() {
+		services = s.findMappedServices(url)
+		if services.Empty() {
+			return s.subscribedServices
+		}
+	}
+	return services
+}
+
+func (s *serviceDiscoveryRegistry) findMappedServices(url common.URL) *gxset.HashSet {
+	serviceInterface := url.GetParam(constant.INTERFACE_KEY, url.Path)
+	group := url.GetParam(constant.GROUP_KEY, "")
+	version := url.GetParam(constant.VERSION_KEY, "")
+	protocol := url.Protocol
+	serviceNames, err := s.serviceNameMapping.Get(serviceInterface, group, version, protocol)
+	if err != nil {
+		logger.Errorf("get serviceInterface:[%s] group:[%s] version:[%s] protocol:[%s] from "+
+			"serviceNameMap error:%s", err.Error())
+		return gxset.NewSet()
+	}
+	return serviceNames
+}
+
+func (s *serviceDiscoveryRegistry) getExportedUrls(subscribedURL common.URL, serviceInstances []registry.ServiceInstance) []common.URL {
+	var filterInstances []registry.ServiceInstance
+	for _, s := range serviceInstances {
+		if !s.IsEnable() || !s.IsHealthy() {
+			continue
+		}
+		metaData := s.GetMetadata()
+		_, ok1 := metaData[constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME]
+		_, ok2 := metaData[constant.METADATA_SERVICE_URLS_PROPERTY_NAME]
+		if !ok1 && !ok2 {
+			continue
+		}
+		filterInstances = append(filterInstances, s)
+	}
+	if len(filterInstances) == 0 {
+		return []common.URL{}
+	}
+	s.prepareServiceRevisionExportedURLs(filterInstances)
+	subscribedURLs := s.cloneExportedURLs(subscribedURL, filterInstances)
+	return subscribedURLs
+}
+
+// comparator is defined as Comparator for skip list to compare the URL
+type comparator common.URL
+
+// Compare is defined as Comparator for skip list to compare the URL
+func (c comparator) Compare(comp cm.Comparator) int {
+	a := common.URL(c).String()
+	b := common.URL(comp.(comparator)).String()
+	switch {
+	case a > b:
+		return 1
+	case a < b:
+		return -1
+	default:
+		return 0
+	}
+}
+
+func (s *serviceDiscoveryRegistry) getExportedUrlsByInst(serviceInstance registry.ServiceInstance) []common.URL {
+	var urls []common.URL
+	metadataStorageType := getExportedStoreType(serviceInstance)
+	metadataProxy := proxy.GetMetadataServiceProxy(metadataStorageType)
+	if metadataProxy == nil {
+		return urls
+	}
+	metadataService := metadataProxy.GetProxy(serviceInstance)
+	if metadataService == nil {
+		return urls
+	}
+	result, err := metadataService.GetExportedURLs("*", "", "", "")
+	if err != nil {
+		logger.Errorf("get exported urls catch error:%s,instance:%+v", err.Error(), serviceInstance)
+		return urls
+	}
+	if result == nil {
+		logger.Errorf("get empty  exported urls,instance:%+v", serviceInstance)
+		return urls
+	}
+	for i := uint64(0); i < result.Len(); i++ {
+		urls = append(urls, common.URL(result.ByPosition(i).(comparator)))
+	}
+	return urls
+}
+
+func (s *serviceDiscoveryRegistry) prepareServiceRevisionExportedURLs(serviceInstances []registry.ServiceInstance) {
+	s.lock.Lock()
+	// 1. expunge stale
+	s.expungeStaleRevisionExportedURLs(serviceInstances)
+	// 2. Initialize
+	s.initRevisionExportedURLs(serviceInstances)
+	s.lock.Unlock()

Review comment:
       i think this lock is too large, can shorten it?

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true
+}
+
+func (s *serviceDiscoveryRegistry) Destroy() {
+	err := s.serviceDiscovery.Destroy()
+	if err != nil {
+		logger.Errorf("destroy serviceDiscovery catch error:%s", err.Error())
+	}
+}
+
+func (s *serviceDiscoveryRegistry) Register(url common.URL) error {
+	if !shouldRegister(url) {
+		return nil
+	}
+	ok, err := s.metaDataService.ExportURL(url)

Review comment:
       i think this method  return error enough

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true
+}
+
+func (s *serviceDiscoveryRegistry) Destroy() {
+	err := s.serviceDiscovery.Destroy()
+	if err != nil {
+		logger.Errorf("destroy serviceDiscovery catch error:%s", err.Error())
+	}
+}
+
+func (s *serviceDiscoveryRegistry) Register(url common.URL) error {
+	if !shouldRegister(url) {
+		return nil
+	}
+	ok, err := s.metaDataService.ExportURL(url)
+	if err != nil {
+		logger.Errorf("The URL[%s] registry catch error:%s!", url.String(), err.Error())
+		return err
+	}
+	if ok {
+		logger.Infof("The URL[%s] registry successfully!", url.String())
+	} else {
+		logger.Warnf("The URL[%s] has been registry!", url.String())
+	}
+	return nil
+}
+
+func shouldRegister(url common.URL) bool {
+	side := url.GetParam(constant.SIDE_KEY, "")
+	if side == constant.PROVIDER_PROTOCOL {
+		return true
+	}
+	logger.Debugf("The URL should not be register.", url.String())
+	return false
+}
+
+func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.NotifyListener) {

Review comment:
       ```suggestion
   func (s *serviceDiscoveryRegistry) Subscribe(url common.URL, notify registry.NotifyListener) {
   ```

##########
File path: registry/service/service_discovery_registry_test.go
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"testing"
+)
+
+var (
+	SERVICE_INTERFACE = "org.apache.dubbo.metadata.MetadataService"
+	GROUP             = "dubbo-provider"
+	VERSION           = "1.0.0"
+)
+
+func TestServiceDiscoveryRegistry_Register(t *testing.T) {
+	//registryURL,_:=common.NewURL("in-memory://localhost:12345",

Review comment:
       delete it  if  useless

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true
+}
+
+func (s *serviceDiscoveryRegistry) Destroy() {
+	err := s.serviceDiscovery.Destroy()
+	if err != nil {
+		logger.Errorf("destroy serviceDiscovery catch error:%s", err.Error())
+	}
+}
+
+func (s *serviceDiscoveryRegistry) Register(url common.URL) error {
+	if !shouldRegister(url) {
+		return nil
+	}
+	ok, err := s.metaDataService.ExportURL(url)
+	if err != nil {
+		logger.Errorf("The URL[%s] registry catch error:%s!", url.String(), err.Error())
+		return err
+	}
+	if ok {
+		logger.Infof("The URL[%s] registry successfully!", url.String())
+	} else {
+		logger.Warnf("The URL[%s] has been registry!", url.String())
+	}
+	return nil
+}
+
+func shouldRegister(url common.URL) bool {
+	side := url.GetParam(constant.SIDE_KEY, "")
+	if side == constant.PROVIDER_PROTOCOL {
+		return true
+	}
+	logger.Debugf("The URL should not be register.", url.String())
+	return false
+}
+
+func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.NotifyListener) {
+	if !shouldSubscribe(*url) {
+		return
+	}
+	_, err := s.metaDataService.SubscribeURL(*url)
+	if err != nil {
+		logger.Errorf("subscribe url[%s] catch error:%s", url.String(), err.Error())
+		return
+	}
+	services := s.getServices(*url)
+	if services.Empty() {
+		logger.Errorf("Should has at least one way to know which services this interface belongs to, "+
+			"subscription url:%s", url.String())
+		return
+	}
+	for _, srv := range services.Values() {
+		serviceName := srv.(string)
+		serviceInstances := s.serviceDiscovery.GetInstances(serviceName)
+		s.subscribe(url, notify, serviceName, serviceInstances)
+		listener := &registry.ServiceInstancesChangedListener{
+			ServiceName: serviceName,
+			ChangedNotify: &InstanceChangeNotify{
+				notify:                   notify,
+				serviceDiscoveryRegistry: s,
+			},
+		}
+		s.registerServiceInstancesChangedListener(*url, listener)
+	}
+
+}
+func (s *serviceDiscoveryRegistry) registerServiceInstancesChangedListener(url common.URL, listener *registry.ServiceInstancesChangedListener) {
+	listenerId := listener.ServiceName + ":" + getUrlKey(url)
+	if !s.subscribedServices.Contains(listenerId) {
+		err := s.serviceDiscovery.AddListener(listener)
+		if err != nil {
+			logger.Errorf("add listener[%s] catch error,url:%s err:%s", listenerId, url.String(), err.Error())
+		}
+	}
+
+}
+
+func getUrlKey(url common.URL) string {
+	var bf bytes.Buffer
+	if len(url.Protocol) != 0 {
+		bf.WriteString(url.Protocol)
+		bf.WriteString("://")
+	}
+	if len(url.Location) != 0 {
+		bf.WriteString(url.Location)
+		bf.WriteString(":")
+		bf.WriteString(url.Port)
+	}
+	if len(url.Path) != 0 {
+		bf.WriteString("/")
+		bf.WriteString(url.Path)
+	}
+	bf.WriteString("?")
+	appendParam(bf, constant.VERSION_KEY, url)
+	appendParam(bf, constant.GROUP_KEY, url)
+	appendParam(bf, constant.NACOS_PROTOCOL_KEY, url)
+	return bf.String()
+}
+
+func appendParam(buffer bytes.Buffer, paramKey string, url common.URL) {
+	buffer.WriteString(paramKey)
+	buffer.WriteString("=")
+	buffer.WriteString(url.GetParam(paramKey, ""))
+}
+
+func (s *serviceDiscoveryRegistry) subscribe(url *common.URL, notify registry.NotifyListener,
+	serviceName string, serviceInstances []registry.ServiceInstance) {
+	if len(serviceInstances) == 0 {
+		logger.Warnf("here is no instance in service[name : %s]", serviceName)
+		return
+	}
+	var subscribedURLs []common.URL
+	subscribedURLs = append(subscribedURLs, s.getExportedUrls(*url, serviceInstances)...)
+	if len(subscribedURLs) == 0 {
+		subscribedURLs = s.synthesizeSubscribedURLs(url, serviceInstances)
+	}
+	//TODO make sure it's workable
+	for _, url := range subscribedURLs {
+		notify.Notify(&registry.ServiceEvent{
+			Action:  remoting.EventTypeAdd,
+			Service: url,
+		})
+	}
+
+}
+
+func (s *serviceDiscoveryRegistry) synthesizeSubscribedURLs(subscribedURL *common.URL, serviceInstances []registry.ServiceInstance) []common.URL {
+	var urls []common.URL
+	for _, syn := range s.subscribedURLsSynthesizers {
+		if syn.Support(subscribedURL) {
+			urls = append(urls, syn.Synthesize(subscribedURL, serviceInstances)...)
+		}
+	}
+	return urls
+}
+func shouldSubscribe(url common.URL) bool {
+	return !shouldRegister(url)
+}
+
+func (s *serviceDiscoveryRegistry) getServices(url common.URL) *gxset.HashSet {
+	services := gxset.NewSet()
+	serviceNames := url.GetParam(constant.PROVIDER_BY, "")
+	if len(serviceNames) != 0 {
+		services = parseServices(serviceNames)
+	}
+	if services.Empty() {
+		services = s.findMappedServices(url)
+		if services.Empty() {
+			return s.subscribedServices
+		}
+	}
+	return services
+}
+
+func (s *serviceDiscoveryRegistry) findMappedServices(url common.URL) *gxset.HashSet {
+	serviceInterface := url.GetParam(constant.INTERFACE_KEY, url.Path)
+	group := url.GetParam(constant.GROUP_KEY, "")
+	version := url.GetParam(constant.VERSION_KEY, "")
+	protocol := url.Protocol
+	serviceNames, err := s.serviceNameMapping.Get(serviceInterface, group, version, protocol)
+	if err != nil {
+		logger.Errorf("get serviceInterface:[%s] group:[%s] version:[%s] protocol:[%s] from "+
+			"serviceNameMap error:%s", err.Error())
+		return gxset.NewSet()
+	}
+	return serviceNames
+}
+
+func (s *serviceDiscoveryRegistry) getExportedUrls(subscribedURL common.URL, serviceInstances []registry.ServiceInstance) []common.URL {
+	var filterInstances []registry.ServiceInstance
+	for _, s := range serviceInstances {
+		if !s.IsEnable() || !s.IsHealthy() {
+			continue
+		}
+		metaData := s.GetMetadata()
+		_, ok1 := metaData[constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME]
+		_, ok2 := metaData[constant.METADATA_SERVICE_URLS_PROPERTY_NAME]
+		if !ok1 && !ok2 {
+			continue
+		}
+		filterInstances = append(filterInstances, s)
+	}
+	if len(filterInstances) == 0 {
+		return []common.URL{}
+	}
+	s.prepareServiceRevisionExportedURLs(filterInstances)
+	subscribedURLs := s.cloneExportedURLs(subscribedURL, filterInstances)
+	return subscribedURLs
+}
+
+// comparator is defined as Comparator for skip list to compare the URL
+type comparator common.URL
+
+// Compare is defined as Comparator for skip list to compare the URL
+func (c comparator) Compare(comp cm.Comparator) int {
+	a := common.URL(c).String()
+	b := common.URL(comp.(comparator)).String()
+	switch {
+	case a > b:
+		return 1
+	case a < b:
+		return -1
+	default:
+		return 0
+	}
+}
+
+func (s *serviceDiscoveryRegistry) getExportedUrlsByInst(serviceInstance registry.ServiceInstance) []common.URL {
+	var urls []common.URL
+	metadataStorageType := getExportedStoreType(serviceInstance)
+	metadataProxy := proxy.GetMetadataServiceProxy(metadataStorageType)
+	if metadataProxy == nil {
+		return urls
+	}
+	metadataService := metadataProxy.GetProxy(serviceInstance)
+	if metadataService == nil {
+		return urls
+	}
+	result, err := metadataService.GetExportedURLs("*", "", "", "")
+	if err != nil {
+		logger.Errorf("get exported urls catch error:%s,instance:%+v", err.Error(), serviceInstance)
+		return urls
+	}
+	if result == nil {
+		logger.Errorf("get empty  exported urls,instance:%+v", serviceInstance)
+		return urls
+	}
+	for i := uint64(0); i < result.Len(); i++ {
+		urls = append(urls, common.URL(result.ByPosition(i).(comparator)))
+	}
+	return urls
+}
+
+func (s *serviceDiscoveryRegistry) prepareServiceRevisionExportedURLs(serviceInstances []registry.ServiceInstance) {
+	s.lock.Lock()
+	// 1. expunge stale
+	s.expungeStaleRevisionExportedURLs(serviceInstances)
+	// 2. Initialize
+	s.initRevisionExportedURLs(serviceInstances)
+	s.lock.Unlock()
+}
+
+func (s *serviceDiscoveryRegistry) expungeStaleRevisionExportedURLs(serviceInstances []registry.ServiceInstance) {
+	serviceName := serviceInstances[0].GetServiceName()
+	revisionExportedURLsMap, exist := s.serviceRevisionExportedURLsCache[serviceName]
+	if !exist {
+		return
+	}
+	existRevision := gxset.NewSet()
+	for k := range revisionExportedURLsMap {
+		existRevision.Add(k)
+	}
+	currentRevision := gxset.NewSet()
+	for _, s := range serviceInstances {
+		rv := getExportedServicesRevision(s)
+		if len(rv) != 0 {

Review comment:
       ```suggestion
   		if len(rv) > 0 {
   ```

##########
File path: registry/service/synthesizer/rest/rest_subscribed_urls_synthesizer.go
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rest
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"net/url"
+	"strings"

Review comment:
       format

##########
File path: registry/service/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rest
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/stretchr/testify/assert"
+	"net/url"
+	"testing"

Review comment:
       format

##########
File path: registry/service/service_discovery_registry.go
##########
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	cm "github.com/Workiva/go-datastructures/common"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/metadata/mapping"
+	"github.com/apache/dubbo-go/metadata/service"
+	"github.com/apache/dubbo-go/metadata/service/inmemory"
+	"github.com/apache/dubbo-go/registry"
+	"github.com/apache/dubbo-go/registry/service/proxy"
+	"github.com/apache/dubbo-go/registry/service/synthesizer"
+	"github.com/apache/dubbo-go/remoting"
+	gxset "github.com/dubbogo/gost/container/set"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+const (
+	SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
+)
+
+func init() {
+	extension.SetRegistry(SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry)
+}
+
+type serviceDiscoveryRegistry struct {
+	lock                             sync.RWMutex
+	url                              *common.URL
+	serviceDiscovery                 registry.ServiceDiscovery
+	subscribedServices               *gxset.HashSet
+	serviceNameMapping               mapping.ServiceNameMapping
+	metaDataService                  service.MetadataService
+	registeredListeners              *gxset.HashSet
+	subscribedURLsSynthesizers       []synthesizer.SubscribedURLsSynthesizer
+	serviceRevisionExportedURLsCache map[string]map[string][]common.URL
+}
+
+func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
+	serviceDiscovery, err := creatServiceDiscovery(url)
+	if err != nil {
+		return nil, err
+	}
+	subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+	subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
+	serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
+	//TODO it's need to get implement by factory
+	metaDataService := inmemory.NewMetadataService()
+	return &serviceDiscoveryRegistry{
+		url:                              url,
+		serviceDiscovery:                 serviceDiscovery,
+		subscribedServices:               subscribedServices,
+		subscribedURLsSynthesizers:       subscribedURLsSynthesizers,
+		registeredListeners:              gxset.NewSet(),
+		serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
+		serviceNameMapping:               serviceNameMapping,
+		metaDataService:                  metaDataService,
+	}, nil
+}
+
+func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
+	return extension.GetServiceDiscovery(url.Protocol, url)
+}
+
+func parseServices(literalServices string) *gxset.HashSet {
+	set := gxset.NewSet()
+	if len(literalServices) == 0 {
+		return set
+	}
+	var splitServices = strings.Split(literalServices, ",")
+	for _, s := range splitServices {
+		if len(s) != 0 {
+			set.Add(s)
+		}
+	}
+	return set
+}
+
+func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery {
+	return s.serviceDiscovery
+}
+
+func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
+	return *s.url
+}
+
+func (s *serviceDiscoveryRegistry) IsAvailable() bool {
+	return true
+}
+
+func (s *serviceDiscoveryRegistry) Destroy() {
+	err := s.serviceDiscovery.Destroy()
+	if err != nil {
+		logger.Errorf("destroy serviceDiscovery catch error:%s", err.Error())
+	}
+}
+
+func (s *serviceDiscoveryRegistry) Register(url common.URL) error {
+	if !shouldRegister(url) {
+		return nil
+	}
+	ok, err := s.metaDataService.ExportURL(url)
+	if err != nil {
+		logger.Errorf("The URL[%s] registry catch error:%s!", url.String(), err.Error())
+		return err
+	}
+	if ok {
+		logger.Infof("The URL[%s] registry successfully!", url.String())
+	} else {
+		logger.Warnf("The URL[%s] has been registry!", url.String())
+	}
+	return nil
+}
+
+func shouldRegister(url common.URL) bool {
+	side := url.GetParam(constant.SIDE_KEY, "")
+	if side == constant.PROVIDER_PROTOCOL {
+		return true
+	}
+	logger.Debugf("The URL should not be register.", url.String())
+	return false
+}
+
+func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.NotifyListener) {
+	if !shouldSubscribe(*url) {
+		return
+	}
+	_, err := s.metaDataService.SubscribeURL(*url)
+	if err != nil {
+		logger.Errorf("subscribe url[%s] catch error:%s", url.String(), err.Error())
+		return
+	}
+	services := s.getServices(*url)
+	if services.Empty() {
+		logger.Errorf("Should has at least one way to know which services this interface belongs to, "+
+			"subscription url:%s", url.String())
+		return
+	}
+	for _, srv := range services.Values() {
+		serviceName := srv.(string)
+		serviceInstances := s.serviceDiscovery.GetInstances(serviceName)
+		s.subscribe(url, notify, serviceName, serviceInstances)
+		listener := &registry.ServiceInstancesChangedListener{
+			ServiceName: serviceName,
+			ChangedNotify: &InstanceChangeNotify{
+				notify:                   notify,
+				serviceDiscoveryRegistry: s,
+			},
+		}
+		s.registerServiceInstancesChangedListener(*url, listener)
+	}
+
+}
+func (s *serviceDiscoveryRegistry) registerServiceInstancesChangedListener(url common.URL, listener *registry.ServiceInstancesChangedListener) {
+	listenerId := listener.ServiceName + ":" + getUrlKey(url)
+	if !s.subscribedServices.Contains(listenerId) {
+		err := s.serviceDiscovery.AddListener(listener)
+		if err != nil {
+			logger.Errorf("add listener[%s] catch error,url:%s err:%s", listenerId, url.String(), err.Error())
+		}
+	}
+
+}
+
+func getUrlKey(url common.URL) string {
+	var bf bytes.Buffer
+	if len(url.Protocol) != 0 {

Review comment:
       ```suggestion
   	if len(url.Protocol) > 0 {
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-io commented on pull request #491: ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491#issuecomment-622966482


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=h1) Report
   > Merging [#491](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=desc) into [feature/dubbo-2.7.5](https://codecov.io/gh/apache/dubbo-go/commit/6a558d875f02f41f52cb97c1e2ce17f1c6031293&el=desc) will **decrease** coverage by `2.16%`.
   > The diff coverage is `6.90%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/491/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL)](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree)
   
   ```diff
   @@                   Coverage Diff                   @@
   ##           feature/dubbo-2.7.5     #491      +/-   ##
   =======================================================
   - Coverage                66.81%   64.65%   -2.17%     
   =======================================================
     Files                      196      199       +3     
     Lines                    10125    10462     +337     
   =======================================================
   - Hits                      6765     6764       -1     
   - Misses                    2708     3042     +334     
   - Partials                   652      656       +4     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [common/extension/service\_discovery.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2Rpc2NvdmVyeS5nbw==) | `0.00% <ø> (ø)` | |
   | [...mon/extension/service\_instance\_selector\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX2luc3RhbmNlX3NlbGVjdG9yX2ZhY3RvcnkuZ28=) | `0.00% <0.00%> (ø)` | |
   | [common/extension/service\_name\_mapping.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29tbW9uL2V4dGVuc2lvbi9zZXJ2aWNlX25hbWVfbWFwcGluZy5nbw==) | `0.00% <0.00%> (ø)` | |
   | [registry/service/service\_discovery\_registry.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZS9zZXJ2aWNlX2Rpc2NvdmVyeV9yZWdpc3RyeS5nbw==) | `0.57% <0.57%> (ø)` | |
   | [...nstance/random/random\_service\_instance\_selector.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZS9pbnN0YW5jZS9yYW5kb20vcmFuZG9tX3NlcnZpY2VfaW5zdGFuY2Vfc2VsZWN0b3IuZ28=) | `66.66% <66.66%> (ø)` | |
   | [...nthesizer/rest/rest\_subscribed\_urls\_synthesizer.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cmVnaXN0cnkvc2VydmljZS9zeW50aGVzaXplci9yZXN0L3Jlc3Rfc3Vic2NyaWJlZF91cmxzX3N5bnRoZXNpemVyLmdv) | `80.95% <80.95%> (ø)` | |
   | [protocol/dubbo/codec.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cHJvdG9jb2wvZHViYm8vY29kZWMuZ28=) | `72.50% <0.00%> (-5.00%)` | :arrow_down: |
   | [config\_center/nacos/impl.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-Y29uZmlnX2NlbnRlci9uYWNvcy9pbXBsLmdv) | `71.08% <0.00%> (-3.66%)` | :arrow_down: |
   | [protocol/dubbo/readwriter.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cHJvdG9jb2wvZHViYm8vcmVhZHdyaXRlci5nbw==) | `68.29% <0.00%> (-2.44%)` | :arrow_down: |
   | [protocol/dubbo/client.go](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree#diff-cHJvdG9jb2wvZHViYm8vY2xpZW50Lmdv) | `67.87% <0.00%> (-1.22%)` | :arrow_down: |
   | ... and [23 more](https://codecov.io/gh/apache/dubbo-go/pull/491/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=footer). Last update [bcda4de...bcda4de](https://codecov.io/gh/apache/dubbo-go/pull/491?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] flycash closed pull request #491: (WIP) ServiceDiscoveryRegistry implementation

Posted by GitBox <gi...@apache.org>.
flycash closed pull request #491:
URL: https://github.com/apache/dubbo-go/pull/491


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org