Skip to content
Snippets Groups Projects
Unverified Commit 75ae61de authored by Xin.Zh's avatar Xin.Zh Committed by GitHub
Browse files

Merge pull request #588 from watermelo/featue/addCommentForMetadata

Mod: add comment for metadata
parents 8845c48e 92a019db
No related branches found
No related tags found
No related merge requests found
......@@ -25,11 +25,13 @@ import (
"github.com/apache/dubbo-go/common/constant"
)
// BaseMetadataIdentifier defined for description the Metadata base identify
type BaseMetadataIdentifier interface {
getFilePathKey(params ...string) string
getIdentifierKey(params ...string) string
}
// BaseMetadataIdentifier is the base implement of BaseMetadataIdentifier interface
type BaseServiceMetadataIdentifier struct {
serviceInterface string
version string
......@@ -37,7 +39,7 @@ type BaseServiceMetadataIdentifier struct {
side string
}
// joinParams...
// joinParams will join the specified char in slice, and return a string
func joinParams(joinChar string, params []string) string {
var joinedStr string
for _, param := range params {
......@@ -47,7 +49,7 @@ func joinParams(joinChar string, params []string) string {
return joinedStr
}
// getIdentifierKey...
// getIdentifierKey returns string that format is service:Version:Group:Side:param1:param2...
func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.serviceInterface +
constant.KEY_SEPARATOR + mdi.version +
......@@ -56,7 +58,7 @@ func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) str
joinParams(constant.KEY_SEPARATOR, params)
}
// getFilePathKey...
// getFilePathKey returns string that format is metadata/path/Version/Group/Side/param1/param2...
func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) string {
path := serviceToPath(mdi.serviceInterface)
......@@ -69,7 +71,6 @@ func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) strin
}
// serviceToPath...
func serviceToPath(serviceInterface string) string {
if serviceInterface == constant.ANY_VALUE {
return ""
......@@ -83,7 +84,6 @@ func serviceToPath(serviceInterface string) string {
}
//withPathSeparator...
func withPathSeparator(path string) string {
if len(path) != 0 {
path = constant.PATH_SEPARATOR + path
......
......@@ -17,17 +17,18 @@
package identifier
// MetadataIdentifier is inherit baseMetaIdentifier with Application name
type MetadataIdentifier struct {
application string
BaseMetadataIdentifier
}
// getIdentifierKey...
// GetIdentifierKey returns string that format is service:Version:Group:Side:Application
func (mdi *MetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.application)
}
// getIdentifierKey...
// GetFilePathKey returns string that format is metadata/path/Version/Group/Side/Application
func (mdi *MetadataIdentifier) getFilePathKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.application)
}
......@@ -21,18 +21,19 @@ import (
"github.com/apache/dubbo-go/common/constant"
)
// ServiceMetadataIdentifier is inherit baseMetaIdentifier with service params: Revision and Protocol
type ServiceMetadataIdentifier struct {
revision string
protocol string
BaseMetadataIdentifier
}
// getIdentifierKey...
// GetIdentifierKey returns string that format is service:Version:Group:Side:Protocol:"revision"+Revision
func (mdi *ServiceMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.protocol + constant.KEY_REVISON_PREFIX + mdi.revision)
}
// getIdentifierKey...
// GetFilePathKey returns string that format is metadata/path/Version/Group/Side/Protocol/"revision"+Revision
func (mdi *ServiceMetadataIdentifier) getFilePathKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.protocol + constant.KEY_REVISON_PREFIX + mdi.revision)
}
......@@ -17,17 +17,18 @@
package identifier
// SubscriberMetadataIdentifier is inherit baseMetaIdentifier with service params: Revision
type SubscriberMetadataIdentifier struct {
revision string
BaseMetadataIdentifier
}
// getIdentifierKey...
// GetIdentifierKey returns string that format is service:Version:Group:Side:Revision
func (mdi *SubscriberMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.revision)
}
// getIdentifierKey...
// GetFilePathKey returns string that format is metadata/path/Version/Group/Side/Revision
func (mdi *SubscriberMetadataIdentifier) getFilePathKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.revision)
}
......@@ -22,6 +22,9 @@ import (
gxset "github.com/dubbogo/gost/container/set"
)
// Metadata service is a built-in service around the metadata of Dubbo services,
// whose interface is provided by Dubbo Framework and exported automatically before subscription after other services exporting,
// which may be used for Dubbo subscribers and admin.
type MetadataService interface {
ServiceName() string
ExportURL(url *common.URL) bool
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment