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
Next Next commit
Add: add comments for metadata direcotory
  • Loading branch information
watermelo committed Jun 6, 2020
commit f4400ef8778fe7b454e7a0b0b8f13ca0007bb59c
7 changes: 2 additions & 5 deletions metadata/identifier/base_metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type BaseServiceMetadataIdentifier struct {
side string
}

// joinParams...
func joinParams(joinChar string, params []string) string {
var joinedStr string
for _, param := range params {
Expand All @@ -47,7 +46,7 @@ func joinParams(joinChar string, params []string) string {
return joinedStr
}

// getIdentifierKey...
// getIdentifierKey gets metadata identifier key by @params
zouyx marked this conversation as resolved.
Show resolved Hide resolved
func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.serviceInterface +
constant.KEY_SEPARATOR + mdi.version +
Expand All @@ -56,7 +55,7 @@ func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) str
joinParams(constant.KEY_SEPARATOR, params)
}

// getFilePathKey...
// getFilePathKey gets metadata file path key by @params
func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) string {
path := serviceToPath(mdi.serviceInterface)

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

}

// serviceToPath...
func serviceToPath(serviceInterface string) string {
if serviceInterface == constant.ANY_VALUE {
return ""
Expand All @@ -83,7 +81,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

// The MetadataIdentifier is used to store method descriptor
type MetadataIdentifier struct {
application string
BaseMetadataIdentifier
}

// getIdentifierKey...
// getIdentifierKey gets metadata identifier key by @mdi.application
func (mdi *MetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.application)
}

// getIdentifierKey...
// getIdentifierKey gets metadata file path key by @mdi.application
func (mdi *MetadataIdentifier) getFilePathKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.application)
}
8 changes: 4 additions & 4 deletions metadata/identifier/service_metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ type ServiceMetadataIdentifier struct {
BaseMetadataIdentifier
}

// getIdentifierKey...
// getIdentifierKey gets metadata identifier key by @mdi.protocol and @mdi.revision
func (mdi *ServiceMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.protocol + constant.KEY_REVISON_PREFIX + mdi.revision)
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.protocol, constant.KEY_REVISON_PREFIX, mdi.revision)
zouyx marked this conversation as resolved.
Show resolved Hide resolved
}

// getIdentifierKey...
// getFilePathKey gets metadata file path key by @mdi.protocol and @mdi.revision
func (mdi *ServiceMetadataIdentifier) getFilePathKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.protocol + constant.KEY_REVISON_PREFIX + mdi.revision)
return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.protocol, constant.KEY_REVISON_PREFIX, mdi.revision)
}
4 changes: 2 additions & 2 deletions metadata/identifier/subscribe_metadata_identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ type SubscriberMetadataIdentifier struct {
BaseMetadataIdentifier
}

// getIdentifierKey...
// getIdentifierKey gets metadata identifier key by @mdi.revision
func (mdi *SubscriberMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.revision)
}

// getIdentifierKey...
// getFilePathKey gets metadata file path key by @mdi.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