diff --git a/common/constant/key.go b/common/constant/key.go
index 9b00d021b7858df72edba9fbd4cc7802b7a2832b..414d24e6e8d51cea960992293a1e20fcd6639504 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -277,6 +277,6 @@ const (
// SERVICE_DISCOVERY_KEY indicate which service discovery instance will be used
SERVICE_DISCOVERY_KEY = "service_discovery"
- LANGUAGE_KEY = "language"
- GO_LANG = "golang"
+ LANGUAGE_KEY = "language"
+ GO_LANG = "golang"
)
diff --git a/metadata/service/inmemory/service_proxy.go b/metadata/service/inmemory/service_proxy.go
index 95ad680f738ac92880b5d4f32db07ca6728134f6..a62d14457d3935efce66f23c2b6badd796cbcd97 100644
--- a/metadata/service/inmemory/service_proxy.go
+++ b/metadata/service/inmemory/service_proxy.go
@@ -25,7 +25,6 @@ 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/metadata/service"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
)
@@ -69,7 +68,7 @@ func (m *MetadataServiceProxy) GetExportedURLs(serviceInterface string, group st
start := time.Now()
res := m.invkr.Invoke(context.Background(), inv)
end := time.Now()
- logger.Infof("duration: ", (end.Sub(start)).String())
+ logger.Infof("duration: %s, result: %v", (end.Sub(start)).String(), res.Result())
if res.Error() != nil {
logger.Errorf("could not get the metadata service from remote provider: %v", res.Error())
return []interface{}{}, nil
@@ -77,17 +76,12 @@ func (m *MetadataServiceProxy) GetExportedURLs(serviceInterface string, group st
urlStrs := res.Result().(*[]interface{})
- ret := make([]common.URL, 0, len(*urlStrs))
+ ret := make([]interface{}, 0, len(*urlStrs))
for _, s := range *urlStrs {
- u, err := common.NewURL(s.(string))
- if err != nil {
- logger.Errorf("could not convert the string to URL: %s", s)
- continue
- }
- ret = append(ret, u)
+ ret = append(ret, s)
}
- return service.ConvertURLArrToIntfArr(ret), nil
+ return ret, nil
}
func (m *MetadataServiceProxy) Reference() string {
diff --git a/metadata/service/service.go b/metadata/service/service.go
index d5673e355216216b87f640f41f36bdefddc8fae4..803a84773f954af82f28c5597444e90833afa831 100644
--- a/metadata/service/service.go
+++ b/metadata/service/service.go
@@ -44,6 +44,7 @@ type MetadataService interface {
// GetExportedURLs will get the target exported url in metadata
// the url should be unique
// due to dubbo-go only support return array []interface{} in RPCService, so we should declare the return type as []interface{}
+ // actually, it's []String
GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]interface{}, error)
// GetExportedURLs will get the target subscribed url in metadata
// the url should be unique
@@ -117,7 +118,7 @@ func ConvertURLArrToIntfArr(urls []common.URL) []interface{} {
res := make([]interface{}, 0, len(urls))
for _, u := range urls {
- res = append(res, u)
+ res = append(res, u.String())
}
return res
-}
\ No newline at end of file
+}
diff --git a/registry/event/metadata_service_url_params_customizer.go b/registry/event/metadata_service_url_params_customizer.go
index 9f791c8337fd2d1e78409786073bac3a2505ca0e..06278f4e7793c8a0c36b9264ede896c1d6243cc8 100644
--- a/registry/event/metadata_service_url_params_customizer.go
+++ b/registry/event/metadata_service_url_params_customizer.go
@@ -81,7 +81,11 @@ func (m *metadataServiceURLParamsMetadataCustomizer) convertToParams(urls []inte
// those keys are useless
for _, ui := range urls {
- u := ui.(common.URL)
+ u, err := common.NewURL(ui.(string))
+ if err != nil {
+ logger.Errorf("could not parse the string to url: %s", ui.(string), err)
+ continue
+ }
p := make(map[string]string, len(u.GetParams()))
for k, v := range u.GetParams() {
// we will ignore that
diff --git a/registry/event/protocol_ports_metadata_customizer.go b/registry/event/protocol_ports_metadata_customizer.go
index eae3f82c200cdc994e44f1c03b3c683d18174bc2..bf16fa8e2fd0a9fc02f377b8ee8c2d8bcca69396 100644
--- a/registry/event/protocol_ports_metadata_customizer.go
+++ b/registry/event/protocol_ports_metadata_customizer.go
@@ -23,11 +23,16 @@ 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/registry"
)
-// ProtocolPortsMetadataCustomizer will update
+func init() {
+ extension.AddCustomizers(&ProtocolPortsMetadataCustomizer{})
+}
+
+// ProtocolPortsMetadataCustomizer will update the endpoints
type ProtocolPortsMetadataCustomizer struct {
}
@@ -48,14 +53,15 @@ func (p *ProtocolPortsMetadataCustomizer) Customize(instance registry.ServiceIns
protocolMap := make(map[string]int, 4)
list, err := metadataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
- if err != nil || list == nil {
+ if err != nil || len(list) == 0 {
logger.Errorf("Could not find exported urls", err)
return
}
for _, ui := range list {
- u := ui.(common.URL)
- if len(u.Protocol) == 0 {
+ u, err := common.NewURL(ui.(string))
+ if err != nil || len(u.Protocol) == 0 {
+ logger.Errorf("the url string is invalid: %s", ui.(string), err)
continue
}
@@ -77,8 +83,8 @@ func endpointsStr(protocolMap map[string]int) string {
endpoints := make([]endpoint, 0, len(protocolMap))
for k, v := range protocolMap {
endpoints = append(endpoints, endpoint{
- port: v,
- protocol: k,
+ Port: v,
+ Protocol: k,
})
}
@@ -91,6 +97,6 @@ func endpointsStr(protocolMap map[string]int) string {
}
type endpoint struct {
- port int
- protocol string
+ Port int `json:"port"`
+ Protocol string `json:"protocol"`
}
diff --git a/registry/event/service_revision_customizer.go b/registry/event/service_revision_customizer.go
index a001f36f6255623d1563eb9bce80330c8174919d..fb1cda01a59537b9cfb850dacbbb661edeade428 100644
--- a/registry/event/service_revision_customizer.go
+++ b/registry/event/service_revision_customizer.go
@@ -104,12 +104,22 @@ func resolveRevision(urls []interface{}) string {
candidates := make([]string, 0, len(urls))
for _, ui := range urls {
- u := ui.(common.URL)
+ u, err := common.NewURL(ui.(string))
+ if err != nil {
+ logger.Errorf("could not parse the string to URL structure")
+ continue
+ }
sk := u.GetParam(constant.INTERFACE_KEY, "")
- for _, m := range u.Methods {
- // methods are part of candidates
- candidates = append(candidates, sk+constant.KEY_SEPARATOR+m)
+
+ if len(u.Methods) == 0 {
+ candidates = append(candidates, sk)
+ } else {
+ for _, m := range u.Methods {
+ // methods are part of candidates
+ candidates = append(candidates, sk+constant.KEY_SEPARATOR+m)
+ }
}
+
// append url params if we need it
}
sort.Sort(sort.StringSlice(candidates))
diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go
index a3899861ab6e3d468b8b8913c8507bb0626c1ef5..41054824a24ab68fe2d18ac47e03d0e6532aae0f 100644
--- a/registry/servicediscovery/service_discovery_registry.go
+++ b/registry/servicediscovery/service_discovery_registry.go
@@ -415,7 +415,14 @@ func (s *serviceDiscoveryRegistry) getExportedUrlsByInst(serviceInstance registr
ret := make([]common.URL, 0, len(result))
for _, ui := range result {
- ret = append(ret, ui.(common.URL))
+
+ u, err := common.NewURL(ui.(string))
+
+ if err != nil {
+ logger.Errorf("could not parse the url string to URL structure: %s", ui.(string), err)
+ continue
+ }
+ ret = append(ret, u)
}
return ret
}