diff --git a/metadata/report/consul/report_test.go b/metadata/report/consul/report_test.go index b982d7176572fc4a0fcadcc252865c8dddd46169..34ee29de945f2b9ac6978a55008048e62f4c6812 100644 --- a/metadata/report/consul/report_test.go +++ b/metadata/report/consul/report_test.go @@ -38,13 +38,12 @@ import ( ) func newProviderRegistryUrl(host string, port int) *common.URL { - url1 := common.NewURLWithOptions( + return common.NewURLWithOptions( common.WithIp(host), common.WithPort(strconv.Itoa(port)), common.WithParams(url.Values{}), common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)), ) - return url1 } func newBaseMetadataIdentifier(side string) *identifier.BaseMetadataIdentifier { diff --git a/metadata/report/report.go b/metadata/report/report.go index 3ef8f5925e6c81c493c8d2ca67e1c5efa3717f55..62a9055e843297bd0d69ad94cb09ece64efda85f 100644 --- a/metadata/report/report.go +++ b/metadata/report/report.go @@ -22,14 +22,39 @@ import ( "github.com/apache/dubbo-go/metadata/identifier" ) -// MetadataReport is an interface of remote metadata report +// MetadataReport is an interface of +// remote metadata report. type MetadataReport interface { + // StoreProviderMetadata stores the metadata. + // Metadata includes the basic info of the server, + // provider info, and other user custom info. StoreProviderMetadata(*identifier.MetadataIdentifier, string) error + + // StoreConsumerMetadata stores the metadata. + // Metadata includes the basic info of the server, + // consumer info, and other user custom info. StoreConsumerMetadata(*identifier.MetadataIdentifier, string) error + + // SaveServiceMetadata saves the metadata. + // Metadata includes the basic info of the server, + // service info, and other user custom info. SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, common.URL) error + + // RemoveServiceMetadata removes the metadata. RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) error + + // GetExportedURLs gets the urls. + // If not found, an empty list will be returned. GetExportedURLs(*identifier.ServiceMetadataIdentifier) ([]string, error) + + // SaveSubscribedData saves the urls. + // If not found, an empty str will be returned. SaveSubscribedData(*identifier.SubscriberMetadataIdentifier, string) error + + // GetSubscribedURLs gets the urls. + // If not found, an empty list will be returned. GetSubscribedURLs(*identifier.SubscriberMetadataIdentifier) ([]string, error) + + // GetServiceDefinition gets the service definition. GetServiceDefinition(*identifier.MetadataIdentifier) (string, error) } diff --git a/metadata/report/zookeeper/report_test.go b/metadata/report/zookeeper/report_test.go index 5d25e3c496dec4d70f221d0f6d5b0dde08ca6304..a1e46e2e8d019c0415699ee409833b392a85b504 100644 --- a/metadata/report/zookeeper/report_test.go +++ b/metadata/report/zookeeper/report_test.go @@ -38,13 +38,12 @@ import ( ) func newProviderRegistryUrl(host string, port int) *common.URL { - url1 := common.NewURLWithOptions( + return common.NewURLWithOptions( common.WithIp(host), common.WithPort(strconv.Itoa(port)), common.WithParams(url.Values{}), common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)), ) - return url1 } func newBaseMetadataIdentifier(side string) *identifier.BaseMetadataIdentifier { diff --git a/registry/consul/utils_test.go b/registry/consul/utils_test.go index 1ef20041391e13fc20f184aa604a5ffc9b33295f..327dd95f7181907f6635c7fe89ef726bdcef5204 100644 --- a/registry/consul/utils_test.go +++ b/registry/consul/utils_test.go @@ -46,43 +46,39 @@ var ( ) func newProviderRegistryUrl(host string, port int) *common.URL { - url1 := common.NewURLWithOptions( + return common.NewURLWithOptions( common.WithIp(host), common.WithPort(strconv.Itoa(port)), common.WithParams(url.Values{}), common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)), ) - return url1 } func newConsumerRegistryUrl(host string, port int) *common.URL { - url1 := common.NewURLWithOptions( + return common.NewURLWithOptions( common.WithIp(host), common.WithPort(strconv.Itoa(port)), common.WithParams(url.Values{}), common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)), ) - return url1 } func newProviderUrl(host string, port int, service string, protocol string) common.URL { - url1 := common.NewURLWithOptions( + return *common.NewURLWithOptions( common.WithIp(host), common.WithPort(strconv.Itoa(port)), common.WithPath(service), common.WithProtocol(protocol), ) - return *url1 } func newConsumerUrl(host string, port int, service string, protocol string) common.URL { - url1 := common.NewURLWithOptions( + return *common.NewURLWithOptions( common.WithIp(host), common.WithPort(strconv.Itoa(port)), common.WithPath(service), common.WithProtocol(protocol), ) - return *url1 } type testServer struct {