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 {
|
||||
if genClient {
|
||||
g.generateServiceClient(gfile, service)
|
||||
g.generateServiceClientMethods(gfile, service, true)
|
||||
g.generateServiceClientMethods(gfile, service, component)
|
||||
}
|
||||
if genServer {
|
||||
generateServiceServer(gfile, service)
|
||||
|
2
main.go
2
main.go
@ -90,7 +90,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
|
||||
case "http":
|
||||
err = g.httpGenerate(component, plugin, genClient, genServer)
|
||||
case "grpc", "drpc", "rpc":
|
||||
err = g.rpcGenerate("rpc", plugin, genClient, genServer)
|
||||
err = g.rpcGenerate(component, plugin, genClient, genServer)
|
||||
case "gorilla":
|
||||
err = g.gorillaGenerate(component, plugin)
|
||||
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 {
|
||||
if genClient {
|
||||
g.generateServiceClient(gfile, service)
|
||||
g.generateServiceClientMethods(gfile, service, false)
|
||||
g.generateServiceClientMethods(gfile, service, component)
|
||||
}
|
||||
if genServer {
|
||||
generateServiceServer(gfile, service)
|
||||
|
7
util.go
7
util.go
@ -45,13 +45,16 @@ func (g *Generator) generateServiceClient(gfile *protogen.GeneratedFile, service
|
||||
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
|
||||
for _, method := range service.Methods {
|
||||
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)
|
||||
|
||||
if http && method.Desc.Options() != nil {
|
||||
if component == "http" && method.Desc.Options() != nil {
|
||||
if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) {
|
||||
opts := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation)
|
||||
if opts != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user