diff --git a/config/reference_config.go b/config/reference_config.go
index 895ab9df26399c1c9a1296e44fba8a284ba2fb6c..807dc3f5c6d3ca77e75abd9c2628657f1c2236f6 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -36,6 +36,7 @@ import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/proxy"
+ "github.com/apache/dubbo-go/metadata/service/remote"
"github.com/apache/dubbo-go/protocol"
)
@@ -259,7 +260,7 @@ func (c *ReferenceConfig) GenericLoad(id string) {
}
func publishConsumerDefinition(url *common.URL) {
- if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil {
+ if remoteMetadataService, err := remote.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil {
remoteMetadataService.PublishServiceDefinition(url)
}
}
diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go
index 89172356b3c6551ca12468bb7f10cf5f914d21bb..f85a7be59ad116a662a0d0e0212050c54f959343 100644
--- a/metadata/report/zookeeper/report.go
+++ b/metadata/report/zookeeper/report.go
@@ -19,8 +19,6 @@ package zookeeper
import (
"encoding/json"
- "github.com/apache/dubbo-go/common/logger"
- "github.com/dubbogo/go-zookeeper/zk"
"strings"
"time"
)
@@ -29,10 +27,12 @@ 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/identifier"
"github.com/apache/dubbo-go/metadata/report"
"github.com/apache/dubbo-go/metadata/report/factory"
"github.com/apache/dubbo-go/remoting/zookeeper"
+ "github.com/dubbogo/go-zookeeper/zk"
)
var (
diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go
index d922af1e059761f055639a369d130a5743988e48..8bd59aa992aadadd5bc962fedd97518bae1c9e76 100644
--- a/metadata/service/remote/service.go
+++ b/metadata/service/remote/service.go
@@ -137,23 +137,3 @@ func (mts *RemoteMetadataService) PublishServiceDefinition(url *common.URL) erro
return nil
}
-
-// GetExportedURLs will be implemented by in memory service
-func (mts *RemoteMetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]interface{}, error) {
- return mts.inMemoryMetadataService.GetExportedURLs(serviceInterface, group, version, protocol)
-}
-
-// GetSubscribedURLs will be implemented by in memory service
-func (mts *RemoteMetadataService) GetSubscribedURLs() ([]*common.URL, error) {
- return mts.inMemoryMetadataService.GetSubscribedURLs()
-}
-
-// GetServiceDefinition will be implemented by in memory service
-func (mts *RemoteMetadataService) GetServiceDefinition(interfaceName string, group string, version string) (string, error) {
- return mts.inMemoryMetadataService.GetServiceDefinition(interfaceName, group, version)
-}
-
-// GetServiceDefinitionByServiceKey will be implemented by in memory service
-func (mts *RemoteMetadataService) GetServiceDefinitionByServiceKey(serviceKey string) (string, error) {
- return mts.inMemoryMetadataService.GetServiceDefinitionByServiceKey(serviceKey)
-}
diff --git a/metadata/service/remote/service_proxy_test.go b/metadata/service/remote/service_proxy_test.go
deleted file mode 100644
index 600880b03d75decd6d0b82b04b5bf605e767505f..0000000000000000000000000000000000000000
--- a/metadata/service/remote/service_proxy_test.go
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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 remote
-
-import (
- "testing"
-)
-import (
- "github.com/stretchr/testify/assert"
-)
-
-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/config/instance"
- "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/metadata/service"
- "github.com/apache/dubbo-go/registry"
-)
-
-func TestMetadataServiceProxy_GetExportedURLs(t *testing.T) {
- pxy := createProxy()
- res, err := pxy.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
- assert.Nil(t, err)
- assert.Len(t, res, 2)
-}
-
-func TestMetadataServiceProxy_GetServiceDefinition(t *testing.T) {
- pxy := createProxy()
- res, err := pxy.GetServiceDefinition(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
- assert.Nil(t, err)
- assert.Equal(t, "definition", res)
-}
-
-// TestMetadataServiceProxy test those unimportant method
-// in fact, we don't use them
-func TestMetadataServiceProxy(t *testing.T) {
- pxy := createProxy()
- _, err := pxy.ServiceName()
- assert.NoError(t, err)
- err = pxy.PublishServiceDefinition(&common.URL{})
- assert.NoError(t, err)
- _, err = pxy.Version()
- assert.NoError(t, err)
- _, err = pxy.GetSubscribedURLs()
- assert.NoError(t, err)
- err = pxy.UnsubscribeURL(&common.URL{})
- assert.NoError(t, err)
- _, err = pxy.GetServiceDefinitionByServiceKey("any")
- assert.NoError(t, err)
- _, err = pxy.ExportURL(&common.URL{})
- assert.NoError(t, err)
- _, err = pxy.SubscribeURL(&common.URL{})
- assert.NoError(t, err)
- _ = pxy.MethodMapper()
- err = pxy.UnexportURL(&common.URL{})
- assert.NoError(t, err)
- _ = pxy.Reference()
- _, err = pxy.RefreshMetadata(constant.ANY_VALUE, constant.ANY_VALUE)
- assert.NoError(t, err)
-}
-
-func createProxy() service.MetadataService {
-
- prepareTest()
-
- ins := ®istry.DefaultServiceInstance{
- Id: "test-id",
- ServiceName: "com.dubbo",
- Host: "localhost",
- Port: 8080,
- Enable: true,
- Healthy: true,
- Metadata: map[string]string{constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"mock":{"timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"20880"}}`},
- }
- return newMetadataServiceProxy(ins)
-}
-
-func prepareTest() {
- extension.SetMetadataReportFactory("mock", func() factory.MetadataReportFactory {
- return &mockMetadataReportFactory{}
- })
- u, _ := common.NewURL("mock://localhost")
- instance.GetMetadataReportInstance(u)
-}
-
-type mockMetadataReportFactory struct {
-}
-
-func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.MetadataReport {
- return &mockMetadataReport{}
-}
-
-type mockMetadataReport struct {
-}
-
-func (m mockMetadataReport) GetAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) {
- panic("implement me")
-}
-
-func (m mockMetadataReport) PublishAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier, info *common.MetadataInfo) error {
- panic("implement me")
-}
-
-func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error {
- panic("implement me")
-}
-
-func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIdentifier, string) error {
- panic("implement me")
-}
-
-func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, *common.URL) error {
- return nil
-}
-
-func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) error {
- panic("implement me")
-}
-
-func (m mockMetadataReport) GetExportedURLs(*identifier.ServiceMetadataIdentifier) ([]string, error) {
- return []string{"mock://localhost1", "mock://localhost2"}, nil
-}
-
-func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIdentifier, string) error {
- return nil
-}
-
-func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIdentifier) ([]string, error) {
- panic("implement me")
-}
-
-func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIdentifier) (string, error) {
- return "definition", nil
-}
diff --git a/registry/event_listener.go b/registry/event_listener.go
index 4f1e5a356ba4e01b1de430ffdde95416e0c4abb2..a6fb31c76b7e6092d5477fc8a62017eccea69a94 100644
--- a/registry/event_listener.go
+++ b/registry/event_listener.go
@@ -17,19 +17,22 @@
package registry
+import (
+ "reflect"
+)
+
+import (
+ 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/logger"
+ "github.com/apache/dubbo-go/common/observer"
"github.com/apache/dubbo-go/metadata/service/inmemory"
"github.com/apache/dubbo-go/metadata/service/remote"
"github.com/apache/dubbo-go/remoting"
- gxset "github.com/dubbogo/gost/container/set"
- "reflect"
-)
-
-import (
- "github.com/apache/dubbo-go/common/observer"
)
// The Service Discovery Changed Event Listener