Documentation
¶
Index ¶
- func Category() string
- func Clean() error
- func GenTemplates(_ *cli.Context) error
- func ProtoTmpl(out, protoFilename string) error
- func RevertTemplate(name string) error
- func ServiceProtoTmpl(src, out, protoFilename, protoType string) (string, error)
- func Update() error
- type Dir
- type DirContext
- type Generator
- func (g *Generator) GenCall(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenClassNameRegisters(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenClient(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenCmd(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenConfig(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenCore(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenDao(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenEtc(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenGrpc(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenHandlers(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenHelper(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenImpl(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenLogic(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenMain(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenPb(ctx DirContext, c *ZRpcContext) error
- func (g *Generator) GenPlugin(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenRpcClientRegisters(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenServer(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenServer2(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenService(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GenSvc(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) GencodecSchemas(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, ...) error
- func (g *Generator) Generate(zctx *ZRpcContext) error
- func (g *Generator) GenerateMtproto(zctx *ZRpcContext) error
- func (g *Generator) GenerateServices(zctxs []*ZRpcContext) error
- func (g *Generator) GetCfg() *conf.Config
- func (g *Generator) Prepare() error
- type ZRpcContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Category ¶
func Category() string
Category returns a const string value for rpc template category
func GenTemplates ¶
GenTemplates is the entry for command goctl template, it will create the specified category
func RevertTemplate ¶
RevertTemplate restores the deleted template files
func ServiceProtoTmpl ¶
ProtoTmpl returns a sample of a proto file
Types ¶
type DirContext ¶
type DirContext interface { GetCall() Dir GetClient() Dir GetCmd() Dir GetCmdd() Dir GetEtc() Dir GetPlugin() Dir GetInternal() Dir GetConfig() Dir GetCore() Dir GetDao() Dir GetLogic() Dir GetServer() Dir GetGrpc() Dir GetService() Dir GetSvc() Dir GetPb() Dir GetProtoGo() Dir GetMain() Dir GetServiceName() stringx.String SetPbDir(pbDir, grpcDir string) }
DirContext defines a rpc service directories context
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator defines the environment needs of rpc service generation
func NewGenerator ¶
NewGenerator returns an instance of Generator
func (*Generator) GenCall ¶
func (g *Generator) GenCall(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenCall generates the rpc client code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc client and shields the details in the pb.
func (*Generator) GenClassNameRegisters ¶
func (g *Generator) GenClassNameRegisters(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenClient generates the rpc client code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc client and shields the details in the pb.
func (*Generator) GenClient ¶
func (g *Generator) GenClient(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenClient generates the rpc client code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc client and shields the details in the pb.
func (*Generator) GenCmd ¶
func (g *Generator) GenCmd(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenCmd generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenConfig ¶
func (g *Generator) GenConfig(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenConfig generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenCore ¶
func (g *Generator) GenCore(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenCore generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenDao ¶
func (g *Generator) GenDao(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenDao generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenEtc ¶
func (g *Generator) GenEtc(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenEtc generates the yaml configuration file of the rpc service, including host, port monitoring configuration items and etcd configuration
func (*Generator) GenGrpc ¶
func (g *Generator) GenGrpc(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenGrpc generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenHandlers ¶
func (g *Generator) GenHandlers(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenHandlers generates the rpc handler code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc handler and shields the details in the pb.
func (*Generator) GenHelper ¶
func (g *Generator) GenHelper(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenHelper generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenImpl ¶
func (g *Generator) GenImpl(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenImpl generates the rpc impl code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc impl and shields the details in the pb.
func (*Generator) GenLogic ¶
func (g *Generator) GenLogic(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenLogic generates the logic file of the rpc service, which corresponds to the RPC definition items in proto.
func (*Generator) GenMain ¶
func (g *Generator) GenMain(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenMain generates the main file of the rpc service, which is an rpc service program call entry
func (*Generator) GenPb ¶
func (g *Generator) GenPb(ctx DirContext, c *ZRpcContext) error
GenPb generates the pb.go file, which is a layer of packaging for protoc to generate gprc, but the commands and flags in protoc are not completely joined in goctl. At present, proto_path(-I) is introduced
func (*Generator) GenPlugin ¶
func (g *Generator) GenPlugin(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenPlugin generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenRpcClientRegisters ¶
func (g *Generator) GenRpcClientRegisters(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenClient generates the rpc client code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc client and shields the details in the pb.
func (*Generator) GenServer ¶
func (g *Generator) GenServer(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenServer generates rpc server file, which is an implementation of rpc server
func (*Generator) GenServer2 ¶
func (g *Generator) GenServer2(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenServer generates rpc server file, which is an implementation of rpc server
func (*Generator) GenService ¶
func (g *Generator) GenService(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenService generates the configuration structure definition file of the rpc service, which contains the zrpc.RpcServerConf configuration item by default. You can specify the naming style of the target file name through config.Config. For details, see https://bitbucket.org/hokego/go-zero/tree/master/tools/goctl/config/config.go
func (*Generator) GenSvc ¶
func (g *Generator) GenSvc(ctx DirContext, _ parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenSvc generates the servicecontext.go file, which is the resource dependency of a service, such as rpc dependency, model dependency, etc.
func (*Generator) GencodecSchemas ¶
func (g *Generator) GencodecSchemas(ctx DirContext, proto parser.Proto, service *parser.Service, cfg *conf.Config, c *ZRpcContext) error
GenClient generates the rpc client code, which is the entry point for the rpc service call. It is a layer of encapsulation for the rpc client and shields the details in the pb.
func (*Generator) Generate ¶
func (g *Generator) Generate(zctx *ZRpcContext) error
Generate generates an rpc service, through the proto file, code storage directory, and proto import parameters to control the source file and target location of the rpc service that needs to be generated
func (*Generator) GenerateMtproto ¶
func (g *Generator) GenerateMtproto(zctx *ZRpcContext) error
Generate generates an rpc service, through the proto file, code storage directory, and proto import parameters to control the source file and target location of the rpc service that needs to be generated
func (*Generator) GenerateServices ¶
func (g *Generator) GenerateServices(zctxs []*ZRpcContext) error
Generate generates an rpc service, through the proto file, code storage directory, and proto import parameters to control the source file and target location of the rpc service that needs to be generated
Source Files
¶
- gen.go
- gencall.go
- genclassnameregister.go
- genclient.go
- gencmd.go
- gencodecschema.go
- genconfig.go
- gencore.go
- gendao.go
- generator.go
- genetc.go
- gengrpc.go
- genhandlers.go
- genhelper.go
- genimpl.go
- genlogic.go
- genmain.go
- genpb.go
- genplugin.go
- genrpcclientregister.go
- genserver.go
- genserver2.go
- genservice.go
- gensvc.go
- mkdir.go
- prototmpl.go
- serviceprototmpl.go
- template.go