Skip to content

Commit

Permalink
Merge pull request #588 from watermelo/featue/addCommentForMetadata
Browse files Browse the repository at this point in the history
Mod: add comment for metadata
  • Loading branch information
AlexStocks authored Jun 10, 2020
2 parents 8845c48 + 92a019d commit 75ae61d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
10 changes: 5 additions & 5 deletions metadata/identifier/base_metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ 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
group string
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 {
Expand All @@ -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 +
Expand All @@ -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)

Expand All @@ -69,7 +71,6 @@ func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) strin

}

// serviceToPath...
func serviceToPath(serviceInterface string) string {
if serviceInterface == constant.ANY_VALUE {
return ""
Expand All @@ -83,7 +84,6 @@ func serviceToPath(serviceInterface string) string {

}

//withPathSeparator...
func withPathSeparator(path string) string {
if len(path) != 0 {
path = constant.PATH_SEPARATOR + path
Expand Down
5 changes: 3 additions & 2 deletions metadata/identifier/metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 3 additions & 2 deletions metadata/identifier/service_metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 3 additions & 2 deletions metadata/identifier/subscribe_metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 3 additions & 0 deletions metadata/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 75ae61d

Please sign in to comment.