Skip to content

Commit

Permalink
fix: update service name
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzhiter committed May 23, 2024
1 parent 39d3c0e commit bacef72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions internal/test/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestThriftGenericServer_invokeRPC(t *testing.T) {
Type: config.Thrift,
Endpoint: []string{thriftServerHost},
IDLPath: thriftFilePath,
Service: "GenericService",
IDLServiceName: "GenericService",
Method: "ExampleMethod",
Data: "{\"Msg\": \"hello\"}",
Transport: config.TTHeader,
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestPbGenericServer_invokeRPC(t *testing.T) {
Type: config.Protobuf,
Endpoint: []string{pbServerHostPort},
IDLPath: pbFilePath,
Service: "GenericService",
IDLServiceName: "GenericService",
Method: "ExampleMethod",
Data: "{\"Msg\": \"hello\"}",
Transport: config.TTHeader,
Expand Down Expand Up @@ -257,13 +257,13 @@ func TestBizErrorGenericServer_invokeRPC(t *testing.T) {
defer bizErrorGenericServer.Stop()

conf := &config.Config{
Type: config.Thrift,
Endpoint: []string{bizErrorServerHost},
IDLPath: thriftFilePath,
Service: "GenericService",
Method: "ExampleMethod",
Transport: config.TTHeader,
BizError: true,
Type: config.Thrift,
Endpoint: []string{bizErrorServerHost},
IDLPath: thriftFilePath,
IDLServiceName: "GenericService",
Method: "ExampleMethod",
Transport: config.TTHeader,
BizError: true,
}

c := client.NewThriftGeneric()
Expand Down
10 changes: 5 additions & 5 deletions pkg/argparse/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func (a *Argument) buildFlags() *flag.FlagSet {
f.StringVar(&a.IDLPath, "idl-path", "", "Specify the path of IDL file.")
f.StringVar(&a.IDLPath, "p", "", "Specify the path of IDL file. (shorthand)")

f.StringVar(&a.Method, "method", "", "Specify the method name in the format `ServiceName/MethodName` or or just `MethodName`, such as `GenericService/ExampleMethod`")
f.StringVar(&a.Method, "m", "", "Specify the method name in the format `ServiceName/MethodName` or just `MethodName`, such as `GenericService/ExampleMethod`. (shorthand)")
f.StringVar(&a.Method, "method", "", "Specify the method name in the format `IDLServiceName/MethodName` or or just `MethodName`, such as `GenericService/ExampleMethod`")
f.StringVar(&a.Method, "m", "", "Specify the method name in the format `IDLServiceName/MethodName` or just `MethodName`, such as `GenericService/ExampleMethod`. (shorthand)")

f.StringVar(&a.File, "file", "", "Specify the file path of input. Must be in JSON format.")
f.StringVar(&a.File, "f", "", "Specify the file path of input. Must be in JSON format. (shorthand)")
Expand Down Expand Up @@ -209,11 +209,11 @@ func (a *Argument) checkService() error {
parts := strings.Split(a.Method, "/")
switch len(parts) {
case 2: // If there is exactly one '/', it's treated as a separator
a.Service = parts[0]
a.IDLServiceName = parts[0]
a.Method = parts[1]
case 1: // If there is no '/', the whole string is treated as the method name
a.Method = parts[0]
a.Service = ""
a.IDLServiceName = ""
default: // If there is more than one '/', it's an error
return errors.New(errors.ArgParseError, "Method name must be in the format `ServiceName/MethodName` or just `MethodName`")
}
Expand Down Expand Up @@ -263,7 +263,7 @@ func (a *Argument) BuildConfig() *config.Config {
Type: a.Type,
IDLPath: a.IDLPath,
Endpoint: a.Endpoint,
Service: a.Service,
IDLServiceName: a.IDLServiceName,
Data: a.Data,
File: a.File,
Transport: a.Transport,
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/generic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (c *ThriftGeneric) Init(Conf *config.Config) error {
return err
}

cli, err := genericclient.NewClient(Conf.Service, c.Generic, c.ClientOpts...)
cli, err := genericclient.NewClient(Conf.IDLServiceName, c.Generic, c.ClientOpts...)
if err != nil {
return err
}
Expand Down Expand Up @@ -254,7 +254,7 @@ func (c *PbGeneric) Init(Conf *config.Config) error {
return err
}

cli, err := genericclient.NewClient(Conf.Service, c.Generic, c.ClientOpts...)
cli, err := genericclient.NewClient(Conf.IDLServiceName, c.Generic, c.ClientOpts...)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Config struct {
Type string
IDLPath string
Endpoint []string
Service string
IDLServiceName string
Method string
Data string
Transport string
Expand Down

0 comments on commit bacef72

Please sign in to comment.