Merge pull request #44 from unistack-org/drpc
fix drpc method name in generator
This commit is contained in:
commit
3591d02d42
2
http.go
2
http.go
@ -41,7 +41,7 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC
|
|||||||
for _, service := range file.Services {
|
for _, service := range file.Services {
|
||||||
if genClient {
|
if genClient {
|
||||||
g.generateServiceClient(gfile, service)
|
g.generateServiceClient(gfile, service)
|
||||||
g.generateServiceClientMethods(gfile, service, true)
|
g.generateServiceClientMethods(gfile, service, component)
|
||||||
}
|
}
|
||||||
if genServer {
|
if genServer {
|
||||||
generateServiceServer(gfile, service)
|
generateServiceServer(gfile, service)
|
||||||
|
2
main.go
2
main.go
@ -90,7 +90,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
|
|||||||
case "http":
|
case "http":
|
||||||
err = g.httpGenerate(component, plugin, genClient, genServer)
|
err = g.httpGenerate(component, plugin, genClient, genServer)
|
||||||
case "grpc", "drpc", "rpc":
|
case "grpc", "drpc", "rpc":
|
||||||
err = g.rpcGenerate("rpc", plugin, genClient, genServer)
|
err = g.rpcGenerate(component, plugin, genClient, genServer)
|
||||||
case "gorilla":
|
case "gorilla":
|
||||||
err = g.gorillaGenerate(component, plugin)
|
err = g.gorillaGenerate(component, plugin)
|
||||||
case "chi":
|
case "chi":
|
||||||
|
2
rpc.go
2
rpc.go
@ -38,7 +38,7 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl
|
|||||||
for _, service := range file.Services {
|
for _, service := range file.Services {
|
||||||
if genClient {
|
if genClient {
|
||||||
g.generateServiceClient(gfile, service)
|
g.generateServiceClient(gfile, service)
|
||||||
g.generateServiceClientMethods(gfile, service, false)
|
g.generateServiceClientMethods(gfile, service, component)
|
||||||
}
|
}
|
||||||
if genServer {
|
if genServer {
|
||||||
generateServiceServer(gfile, service)
|
generateServiceServer(gfile, service)
|
||||||
|
7
util.go
7
util.go
@ -45,13 +45,16 @@ func (g *Generator) generateServiceClient(gfile *protogen.GeneratedFile, service
|
|||||||
gfile.P()
|
gfile.P()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, http bool) {
|
func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, component string) {
|
||||||
serviceName := service.GoName
|
serviceName := service.GoName
|
||||||
for _, method := range service.Methods {
|
for _, method := range service.Methods {
|
||||||
methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName)
|
methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName)
|
||||||
|
if component == "drpc" {
|
||||||
|
methodName = fmt.Sprintf("%s.%s", method.Parent.Desc.FullName(), method.Desc.Name())
|
||||||
|
}
|
||||||
g.generateClientFuncSignature(gfile, serviceName, method)
|
g.generateClientFuncSignature(gfile, serviceName, method)
|
||||||
|
|
||||||
if http && method.Desc.Options() != nil {
|
if component == "http" && method.Desc.Options() != nil {
|
||||||
if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) {
|
if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) {
|
||||||
opts := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation)
|
opts := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation)
|
||||||
if opts != nil {
|
if opts != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user