|
|
@ -52,7 +52,7 @@ func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} {
|
|
|
|
|
|
|
|
|
|
|
|
callFunctionTemplate = `
|
|
|
|
callFunctionTemplate = `
|
|
|
|
{{if .hasComment}}{{.comment}}{{end}}
|
|
|
|
{{if .hasComment}}{{.comment}}{{end}}
|
|
|
|
func (m *default{{.rpcServiceName}}) {{.method}}(ctx context.Context,in *{{.pbRequest}}) (*{{.pbResponse}}, error) {
|
|
|
|
func (m *default{{.serviceName}}) {{.method}}(ctx context.Context,in *{{.pbRequest}}) (*{{.pbResponse}}, error) {
|
|
|
|
client := {{.package}}.New{{.rpcServiceName}}Client(m.cli.Conn())
|
|
|
|
client := {{.package}}.New{{.rpcServiceName}}Client(m.cli.Conn())
|
|
|
|
return client.{{.method}}(ctx, in)
|
|
|
|
return client.{{.method}}(ctx, in)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -90,9 +90,9 @@ func (g *defaultGenerator) GenCall(ctx DirContext, proto parser.Proto) error {
|
|
|
|
"name": formatFilename(service.Name),
|
|
|
|
"name": formatFilename(service.Name),
|
|
|
|
"alias": strings.Join(alias.KeysStr(), util.NL),
|
|
|
|
"alias": strings.Join(alias.KeysStr(), util.NL),
|
|
|
|
"head": head,
|
|
|
|
"head": head,
|
|
|
|
"filePackage": formatFilename(service.Name),
|
|
|
|
"filePackage": dir.Base,
|
|
|
|
"package": fmt.Sprintf(`"%s"`, ctx.GetPb().Package),
|
|
|
|
"package": fmt.Sprintf(`"%s"`, ctx.GetPb().Package),
|
|
|
|
"serviceName": parser.CamelCase(service.Name),
|
|
|
|
"serviceName": stringx.From(service.Name).ToCamel(),
|
|
|
|
"functions": strings.Join(functions, util.NL),
|
|
|
|
"functions": strings.Join(functions, util.NL),
|
|
|
|
"interface": strings.Join(iFunctions, util.NL),
|
|
|
|
"interface": strings.Join(iFunctions, util.NL),
|
|
|
|
}, filename, true)
|
|
|
|
}, filename, true)
|
|
|
@ -109,8 +109,9 @@ func (g *defaultGenerator) genFunction(goPackage string, service parser.Service)
|
|
|
|
|
|
|
|
|
|
|
|
comment := parser.GetComment(rpc.Doc())
|
|
|
|
comment := parser.GetComment(rpc.Doc())
|
|
|
|
buffer, err := util.With("sharedFn").Parse(text).Execute(map[string]interface{}{
|
|
|
|
buffer, err := util.With("sharedFn").Parse(text).Execute(map[string]interface{}{
|
|
|
|
"rpcServiceName": stringx.From(service.Name).Title(),
|
|
|
|
"serviceName": stringx.From(service.Name).ToCamel(),
|
|
|
|
"method": stringx.From(rpc.Name).Title(),
|
|
|
|
"rpcServiceName": parser.CamelCase(service.Name),
|
|
|
|
|
|
|
|
"method": parser.CamelCase(rpc.Name),
|
|
|
|
"package": goPackage,
|
|
|
|
"package": goPackage,
|
|
|
|
"pbRequest": parser.CamelCase(rpc.RequestType),
|
|
|
|
"pbRequest": parser.CamelCase(rpc.RequestType),
|
|
|
|
"pbResponse": parser.CamelCase(rpc.ReturnsType),
|
|
|
|
"pbResponse": parser.CamelCase(rpc.ReturnsType),
|
|
|
@ -140,7 +141,7 @@ func (g *defaultGenerator) getInterfaceFuncs(service parser.Service) ([]string,
|
|
|
|
map[string]interface{}{
|
|
|
|
map[string]interface{}{
|
|
|
|
"hasComment": len(comment) > 0,
|
|
|
|
"hasComment": len(comment) > 0,
|
|
|
|
"comment": comment,
|
|
|
|
"comment": comment,
|
|
|
|
"method": stringx.From(rpc.Name).Title(),
|
|
|
|
"method": parser.CamelCase(rpc.Name),
|
|
|
|
"pbRequest": parser.CamelCase(rpc.RequestType),
|
|
|
|
"pbRequest": parser.CamelCase(rpc.RequestType),
|
|
|
|
"pbResponse": parser.CamelCase(rpc.ReturnsType),
|
|
|
|
"pbResponse": parser.CamelCase(rpc.ReturnsType),
|
|
|
|
})
|
|
|
|
})
|
|
|
|