generate client and server types in micro file

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2023-07-30 23:54:05 +03:00
parent 86e3dafc12
commit ec03ee131e
4 changed files with 3 additions and 5 deletions

View File

@ -39,11 +39,9 @@ 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.generateServiceClientMethods(gfile, service, component) g.generateServiceClientMethods(gfile, service, component)
} }
if genServer { if genServer {
generateServiceServer(gfile, service)
g.generateServiceServerMethods(gfile, service) g.generateServiceServerMethods(gfile, service)
g.generateServiceRegister(gfile, service, component) g.generateServiceRegister(gfile, service, component)
} }

View File

@ -42,10 +42,12 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen
g.generateServiceName(gfile, service) g.generateServiceName(gfile, service)
g.generateServiceEndpoints(gfile, service, component) g.generateServiceEndpoints(gfile, service, component)
if genClient { if genClient {
g.generateServiceClient(gfile, service)
g.generateServiceClientInterface(gfile, service) g.generateServiceClientInterface(gfile, service)
g.generateServiceClientStreamInterface(gfile, service) g.generateServiceClientStreamInterface(gfile, service)
} }
if genServer { if genServer {
g.generateServiceServer(gfile, service)
g.generateServiceServerInterface(gfile, service) g.generateServiceServerInterface(gfile, service)
g.generateServiceServerStreamInterface(gfile, service) g.generateServiceServerStreamInterface(gfile, service)
} }

2
rpc.go
View File

@ -37,11 +37,9 @@ 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.generateServiceClientMethods(gfile, service, component) g.generateServiceClientMethods(gfile, service, component)
} }
if genServer { if genServer {
generateServiceServer(gfile, service)
g.generateServiceServerMethods(gfile, service) g.generateServiceServerMethods(gfile, service)
g.generateServiceRegister(gfile, service, component) g.generateServiceRegister(gfile, service, component)
} }

View File

@ -319,7 +319,7 @@ func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile,
} }
} }
func generateServiceServer(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceServer(gfile *protogen.GeneratedFile, service *protogen.Service) {
serviceName := service.GoName serviceName := service.GoName
gfile.P("type ", unexport(serviceName), "Server struct {") gfile.P("type ", unexport(serviceName), "Server struct {")
gfile.P(serviceName, "Server") gfile.P(serviceName, "Server")