hxmhlt commented on a change in pull request #471:
URL: https://github.com/apache/dubbo-go/pull/471#discussion_r412049924



##########
File path: metadata/definition/definition.go
##########
@@ -39,3 +51,39 @@ type TypeDefinition struct {
        Properties      map[string]TypeDefinition
        TypeBuilderName string
 }
+
+// BuildServiceDefinition can build service definition which will be used to 
describe a service
+func BuildServiceDefinition(service common.Service, url common.URL) 
ServiceDefinition {
+       sd := ServiceDefinition{}
+       sd.CanonicalName = url.Service()
+
+       for k, m := range service.Method() {
+               var paramTypes []string
+               for _, t := range m.ArgsType() {
+                       paramTypes = append(paramTypes, t.Kind().String())
+               }
+               methodD := MethodDefinition{
+                       Name:           k,
+                       ParameterTypes: paramTypes,
+                       ReturnType:     m.ReplyType().Kind().String(),
+               }
+               sd.Methods = append(sd.Methods, methodD)
+       }
+
+       return sd
+}
+
+// ServiceDescriperBuild: build the service key, format is 
`group/serviceName:version` which be same as URL's service key
+func ServiceDescriperBuild(serviceName string, group string, version string) 
string {
+       buf := &bytes.Buffer{}
+       if group != "" {
+               buf.WriteString(group)
+               buf.WriteString(constant.PATH_SEPARATOR)
+       }
+       buf.WriteString(serviceName)
+       if version != "" && version != "0.0.0" {

Review comment:
       just be same as java




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to