From bacef728ea2598fcef395a5c060ed3e18f5c2df4 Mon Sep 17 00:00:00 2001 From: Zzhiter <2631992879@qq.com> Date: Thu, 23 May 2024 09:18:46 +0800 Subject: [PATCH] fix: update service name --- internal/test/client_test.go | 18 +++++++++--------- pkg/argparse/args.go | 10 +++++----- pkg/client/generic_client.go | 4 ++-- pkg/config/config.go | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/test/client_test.go b/internal/test/client_test.go index 0a7a2ff..76e00cd 100644 --- a/internal/test/client_test.go +++ b/internal/test/client_test.go @@ -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, @@ -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, @@ -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() diff --git a/pkg/argparse/args.go b/pkg/argparse/args.go index 8bc68a1..42e7eea 100644 --- a/pkg/argparse/args.go +++ b/pkg/argparse/args.go @@ -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)") @@ -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`") } @@ -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, diff --git a/pkg/client/generic_client.go b/pkg/client/generic_client.go index d07b273..8261589 100644 --- a/pkg/client/generic_client.go +++ b/pkg/client/generic_client.go @@ -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 } @@ -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 } diff --git a/pkg/config/config.go b/pkg/config/config.go index 1cbd308..12fb042 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -37,7 +37,7 @@ type Config struct { Type string IDLPath string Endpoint []string - Service string + IDLServiceName string Method string Data string Transport string