From ec03ee131e7111142c0daa7d85d61368d5a00781 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 30 Jul 2023 23:54:05 +0300 Subject: [PATCH] generate client and server types in micro file Signed-off-by: Vasiliy Tolstov --- http.go | 2 -- micro.go | 2 ++ rpc.go | 2 -- util.go | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/http.go b/http.go index a9c0335..af1bbbb 100644 --- a/http.go +++ b/http.go @@ -39,11 +39,9 @@ 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, component) } if genServer { - generateServiceServer(gfile, service) g.generateServiceServerMethods(gfile, service) g.generateServiceRegister(gfile, service, component) } diff --git a/micro.go b/micro.go index 413e979..14b192f 100644 --- a/micro.go +++ b/micro.go @@ -42,10 +42,12 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen g.generateServiceName(gfile, service) g.generateServiceEndpoints(gfile, service, component) if genClient { + g.generateServiceClient(gfile, service) g.generateServiceClientInterface(gfile, service) g.generateServiceClientStreamInterface(gfile, service) } if genServer { + g.generateServiceServer(gfile, service) g.generateServiceServerInterface(gfile, service) g.generateServiceServerStreamInterface(gfile, service) } diff --git a/rpc.go b/rpc.go index 2160468..5e960a8 100644 --- a/rpc.go +++ b/rpc.go @@ -37,11 +37,9 @@ 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, component) } if genServer { - generateServiceServer(gfile, service) g.generateServiceServerMethods(gfile, service) g.generateServiceRegister(gfile, service, component) } diff --git a/util.go b/util.go index 8e54fec..b34b714 100644 --- a/util.go +++ b/util.go @@ -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 gfile.P("type ", unexport(serviceName), "Server struct {") gfile.P(serviceName, "Server") -- 2.45.2