Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:change the parameter service to server_name #190

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/static/server_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func serverFlags() []cli.Flag {
globalArgs := config.GetGlobalArgs()
return []cli.Flag{
&cli.StringFlag{Name: consts.Service, Usage: "Specify the service name.", Destination: &globalArgs.ServerArgument.Service},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改下描述,说明一下不推荐使用了?

&cli.StringFlag{Name: consts.ServerName, Usage: "Specify the server name.", Destination: &globalArgs.ServerArgument.ServerName},
li-jin-gou marked this conversation as resolved.
Show resolved Hide resolved
&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
13 changes: 7 additions & 6 deletions config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ 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
Service string // service name
ServerName string //server name
li-jin-gou marked this conversation as resolved.
Show resolved Hide resolved
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.Service == "" && ca.ServerName == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

return errors.New("must specify server name when use registry")
}

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

hzArgument.IdlPaths = []string{abPath}
hzArgument.Gomod = ca.GoMod
hzArgument.ServiceName = ca.Service
if ca.Service != "" {
hzArgument.ServiceName = ca.Service
}
if ca.ServerName != "" {
hzArgument.ServiceName = ca.ServerName
}
hzArgument.Includes = ca.SliceParam.ProtoSearchPath
hzArgument.Cwd = ca.Cwd
hzArgument.Gosrc = ca.GoSrc
Expand Down
6 changes: 6 additions & 0 deletions pkg/client/kitex.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func convertKitexArgs(sa *config.ClientArgument, kitexArgument *kargs.Arguments)

kitexArgument.ModuleName = sa.GoMod
kitexArgument.ServiceName = sa.Service
if sa.Service != "" {
kitexArgument.ServiceName = sa.Service
}
if sa.ServerName != "" {
kitexArgument.ServiceName = sa.ServerName
}
kitexArgument.Includes = sa.SliceParam.ProtoSearchPath
kitexArgument.Version = kitex.Version
kitexArgument.RecordCmd = os.Args
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.Service == "" && sa.ServerName == "" {
return errors.New("must specify server name")
}

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

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

kitexArgument.ModuleName = sa.GoMod
kitexArgument.ServiceName = sa.Service
if sa.Service != "" {
kitexArgument.ServiceName = sa.Service
}
if sa.ServerName != "" {
kitexArgument.ServiceName = sa.ServerName
}
kitexArgument.Includes = sa.SliceParam.ProtoSearchPath
kitexArgument.Version = kitex.Version
kitexArgument.RecordCmd = os.Args
Expand Down