Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod: add comment for metadata #588

Merged
merged 9 commits into from
Jun 10, 2020
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 will return string format as 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 will return string format as 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 will return string format as service:Version:Group:Side:Application
func (mdi *MetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.application)
}

// getIdentifierKey...
// GetFilePathKey will return string format as 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 will return string format as 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 will return string format as 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 will return string format as service:Version:Group:Side:Revision
zouyx marked this conversation as resolved.
Show resolved Hide resolved
func (mdi *SubscriberMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.revision)
}

// getIdentifierKey...
// GetFilePathKey will return string format as 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