feat: Remove command `goctl rpc proto` (#1665)
* Fix goctl completion expression * Fix code generation error if the pkg of pb/grpc is same to zrpc call client pkg * Remove deprecated comment on action goctl rpc new * Remove zrpc code generation on action goctl rpc proto * Remove zrpc code generation on action goctl rpc proto * Remove Generator interface Co-authored-by: anqiansong <anqiansong@bytedance.com>master
parent
448029aa4b
commit
227104d7d7
@ -1,28 +0,0 @@
|
|||||||
package generator
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/env"
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/console"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DefaultGenerator defines the environment needs of rpc service generation
|
|
||||||
type DefaultGenerator struct {
|
|
||||||
log console.Console
|
|
||||||
}
|
|
||||||
|
|
||||||
// just test interface implement
|
|
||||||
var _ Generator = (*DefaultGenerator)(nil)
|
|
||||||
|
|
||||||
// NewDefaultGenerator returns an instance of DefaultGenerator
|
|
||||||
func NewDefaultGenerator() Generator {
|
|
||||||
log := console.NewColorConsole()
|
|
||||||
return &DefaultGenerator{
|
|
||||||
log: log,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare provides environment detection generated by rpc service,
|
|
||||||
// including go environment, protoc, whether protoc-gen-go is installed or not
|
|
||||||
func (g *DefaultGenerator) Prepare() error {
|
|
||||||
return env.Prepare(true, true)
|
|
||||||
}
|
|
@ -1,19 +1,34 @@
|
|||||||
package generator
|
package generator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
conf "github.com/zeromicro/go-zero/tools/goctl/config"
|
conf "github.com/zeromicro/go-zero/tools/goctl/config"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/rpc/parser"
|
"github.com/zeromicro/go-zero/tools/goctl/env"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/util/console"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generator defines a generator interface to describe how to generate rpc service
|
// Generator defines the environment needs of rpc service generation
|
||||||
type Generator interface {
|
type Generator struct {
|
||||||
Prepare() error
|
log console.Console
|
||||||
GenMain(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
cfg *conf.Config
|
||||||
GenCall(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
}
|
||||||
GenEtc(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
|
||||||
GenConfig(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
// NewGenerator returns an instance of Generator
|
||||||
GenLogic(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
func NewGenerator(style string) *Generator {
|
||||||
GenServer(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
cfg, err := conf.NewConfig(style)
|
||||||
GenSvc(ctx DirContext, proto parser.Proto, cfg *conf.Config) error
|
if err != nil {
|
||||||
GenPb(ctx DirContext, protoImportPath []string, proto parser.Proto, cfg *conf.Config, c *ZRpcContext, goOptions ...string) error
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
log := console.NewColorConsole()
|
||||||
|
return &Generator{
|
||||||
|
log: log,
|
||||||
|
cfg: cfg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare provides environment detection generated by rpc service,
|
||||||
|
// including go environment, protoc, whether protoc-gen-go is installed or not
|
||||||
|
func (g *Generator) Prepare() error {
|
||||||
|
return env.Prepare(true, true)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue