Skip to content

Commit

Permalink
fix:change the parameter service to server_name (cloudwego#190)
Browse files Browse the repository at this point in the history
* fix:change the parameter service to server_name

* fix:modify two variables to point to one parameter

* fix:service parameter description
  • Loading branch information
yuxialuozi authored May 31, 2024
1 parent 2bd4f6f commit ce07e0a
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 20 deletions.
3 changes: 2 additions & 1 deletion cmd/static/client_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
func clientFlags() []cli.Flag {
globalArgs := config.GetGlobalArgs()
return []cli.Flag{
&cli.StringFlag{Name: consts.Service, Usage: "Specify the service name.", Destination: &globalArgs.ClientArgument.Service},
&cli.StringFlag{Name: consts.Service, Usage: "Specify the server name.(Not recommended,Deprecate in v0.2.0)", Destination: &globalArgs.ClientArgument.ServerName},
&cli.StringFlag{Name: consts.ServerName, Usage: "Specify the server name.", Destination: &globalArgs.ClientArgument.ServerName},
&cli.StringFlag{Name: consts.ServiceType, Usage: "Specify the generate type. (RPC or HTTP)", Value: consts.RPC},
&cli.StringFlag{Name: consts.Module, Aliases: []string{"mod"}, Usage: "Specify the Go module name to generate go.mod.", Destination: &globalArgs.ClientArgument.GoMod},
&cli.StringFlag{Name: consts.IDLPath, Usage: "Specify the IDL file path. (.thrift or .proto)", Destination: &globalArgs.ClientArgument.IdlPath},
Expand Down
3 changes: 2 additions & 1 deletion cmd/static/server_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
func serverFlags() []cli.Flag {
globalArgs := config.GetGlobalArgs()
return []cli.Flag{
&cli.StringFlag{Name: consts.Service, Usage: "Specify the service name.", Destination: &globalArgs.ServerArgument.Service},
&cli.StringFlag{Name: consts.Service, Usage: "Specify the server name.(Not recommended,Deprecate in v0.2.0)", Destination: &globalArgs.ServerArgument.ServerName},
&cli.StringFlag{Name: consts.ServerName, Usage: "Specify the server name.", Destination: &globalArgs.ServerArgument.ServerName},
&cli.StringFlag{Name: consts.ServiceType, Usage: "Specify the generate type. (RPC or HTTP)", Value: consts.RPC},
&cli.StringFlag{Name: consts.Module, Aliases: []string{"mod"}, Usage: "Specify the Go module name to generate go.mod.", Destination: &globalArgs.ServerArgument.GoMod},
&cli.StringFlag{Name: consts.IDLPath, Usage: "Specify the IDL file path. (.thrift or .proto)", Destination: &globalArgs.ServerArgument.IdlPath},
Expand Down
12 changes: 6 additions & 6 deletions config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ type ServerArgument struct {
}

type CommonParam struct {
Service string // service name
Type string // GenerateType: RPC or HTTP
GoMod string // Go Mod name
IdlPath string
OutDir string // output path
Registry string
ServerName string // server name
Type string // GenerateType: RPC or HTTP
GoMod string // Go Mod name
IdlPath string
OutDir string // output path
Registry string
}

func NewServerArgument() *ServerArgument {
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func check(ca *config.ClientArgument) error {
return errors.New("unsupported registry")
}

if ca.Service == "" {
return errors.New("must specify service name when use registry")
if ca.ServerName == "" {
return errors.New("must specify server name")
}

// handle cwd and output dir
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/hz.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func convertHzArgument(ca *config.ClientArgument, hzArgument *hzConfig.Argument)

hzArgument.IdlPaths = []string{abPath}
hzArgument.Gomod = ca.GoMod
hzArgument.ServiceName = ca.Service
hzArgument.ServiceName = ca.ServerName
hzArgument.Includes = ca.SliceParam.ProtoSearchPath
hzArgument.Cwd = ca.Cwd
hzArgument.Gosrc = ca.GoSrc
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/kitex.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func convertKitexArgs(sa *config.ClientArgument, kitexArgument *kargs.Arguments)
f := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)

kitexArgument.ModuleName = sa.GoMod
kitexArgument.ServiceName = sa.Service
kitexArgument.ServiceName = sa.ServerName
kitexArgument.Includes = sa.SliceParam.ProtoSearchPath
kitexArgument.Version = kitex.Version
kitexArgument.RecordCmd = os.Args
Expand Down
8 changes: 4 additions & 4 deletions pkg/common/kx_registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func HandleRegistry(ca *config.CommonParam, dir string) {
te.Dependencies["github.com/kitex-contrib/registry-etcd"] = "etcd"
te.ExtendServer = &generator.APIExtension{
ImportPaths: append(importPath, "github.com/kitex-contrib/registry-etcd", "github.com/cloudwego/kitex/pkg/rpcinfo"),
ExtendOption: fmt.Sprintf(etcdServer, ca.Service),
ExtendOption: fmt.Sprintf(etcdServer, ca.ServerName),
}
te.ExtendClient = &generator.APIExtension{
ImportPaths: append(importPath, "github.com/kitex-contrib/registry-etcd"),
Expand All @@ -64,18 +64,18 @@ func HandleRegistry(ca *config.CommonParam, dir string) {
te.Dependencies["github.com/cloudwego/kitex/pkg/registry"] = "registry"
te.ExtendServer = &generator.APIExtension{
ImportPaths: []string{"github.com/cloudwego/kitex/pkg/registry", "github.com/kitex-contrib/registry-polaris", "github.com/cloudwego/kitex/pkg/klog"},
ExtendOption: fmt.Sprintf(polarisServer, ca.Service),
ExtendOption: fmt.Sprintf(polarisServer, ca.ServerName),
}
te.ExtendClient = &generator.APIExtension{
ImportPaths: []string{"github.com/cloudwego/kitex/pkg/registry", "github.com/kitex-contrib/registry-polaris", "github.com/cloudwego/kitex/pkg/klog"},
ExtendOption: fmt.Sprintf(polarisClient, ca.Service),
ExtendOption: fmt.Sprintf(polarisClient, ca.ServerName),
}
case consts.Nacos:
te.Dependencies["github.com/kitex-contrib/registry-nacos/registry"] = "registry"
te.Dependencies["github.com/kitex-contrib/registry-nacos/resolver"] = "resolver"
te.ExtendServer = &generator.APIExtension{
ImportPaths: []string{"github.com/cloudwego/kitex/pkg/klog", "github.com/kitex-contrib/registry-nacos/registry", "github.com/cloudwego/kitex/pkg/rpcinfo"},
ExtendOption: fmt.Sprintf(nacosServer, ca.Service),
ExtendOption: fmt.Sprintf(nacosServer, ca.ServerName),
}
te.ExtendClient = &generator.APIExtension{
ImportPaths: []string{"github.com/cloudwego/kitex/pkg/klog", "github.com/kitex-contrib/registry-nacos/resolver"},
Expand Down
1 change: 1 addition & 0 deletions pkg/consts/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const (
DaoDir = "dao_dir"

Service = "service"
ServerName = "server_name"
ServiceType = "type"
Module = "module"
IDLPath = "idl"
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func check(sa *config.ServerArgument) error {
return errors.New("unsupported registry")
}

if sa.Service == "" {
return errors.New("must specify service name")
if sa.ServerName == "" {
return errors.New("must specify server name")
}

// handle cwd and output dir
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/hz.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func convertHzArgument(sa *config.ServerArgument, hzArgument *hzConfig.Argument)

hzArgument.IdlPaths = []string{abPath}
hzArgument.Gomod = sa.GoMod
hzArgument.ServiceName = sa.Service
hzArgument.ServiceName = sa.ServerName
hzArgument.OutDir = sa.OutDir
hzArgument.Includes = sa.SliceParam.ProtoSearchPath
hzArgument.Cwd = sa.Cwd
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/kitex.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func convertKitexArgs(sa *config.ServerArgument, kitexArgument *kargs.Arguments)
f := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)

kitexArgument.ModuleName = sa.GoMod
kitexArgument.ServiceName = sa.Service
kitexArgument.ServiceName = sa.ServerName
kitexArgument.Includes = sa.SliceParam.ProtoSearchPath
kitexArgument.Version = kitex.Version
kitexArgument.RecordCmd = os.Args
Expand Down

0 comments on commit ce07e0a

Please sign in to comment.