package gd_management import ( "context" "fmt" "runtime" "time" "github.com/smallnest/rpcx/client" "github.com/smallnest/rpcx/protocol" "github.com/smallnest/rpcx/share" ) type GdManagementXClient struct { xcli client.XClient } func (a *GdManagementXClient) Init(etcdAddrs []string, basePath, servicePath string) { opt := client.Option{ Retries: 3, RPCPath: share.DefaultRPCPath, ConnectTimeout: 10 * time.Second, SerializeType: protocol.JSON, CompressType: protocol.None, BackupLatency: 10 * time.Millisecond, } if runtime.GOOS == "windows" { d := client.NewEtcdDiscovery(fmt.Sprintf("/%s", basePath), servicePath, etcdAddrs, nil) a.xcli = client.NewXClient(servicePath, client.Failtry, client.RandomSelect, d, opt) } else { d := client.NewEtcdDiscovery(basePath, servicePath, etcdAddrs, nil) a.xcli = client.NewXClient(servicePath, client.Failtry, client.RandomSelect, d, opt) } } func (a *GdManagementXClient) InitForK8s(servicePath string, k8sServiceName string, k8sServicePort string) { opt := client.Option{ Retries: 1, RPCPath: share.DefaultRPCPath, ConnectTimeout: 10 * time.Second, SerializeType: protocol.JSON, CompressType: protocol.None, BackupLatency: 10 * time.Millisecond, } sd := client.NewPeer2PeerDiscovery(fmt.Sprintf("tcp@%s:%s", k8sServiceName, k8sServicePort), "") a.xcli = client.NewXClient(servicePath, client.Failtry, client.RandomSelect, sd, opt) } func (a *GdManagementXClient) ManagementGetProviderApiLimitCount(ctx context.Context, req *ManagementGetProviderApiLimitCountReq) (reply ManagementGetProviderApiLimitCountReply, err error) { err = a.xcli.Call(ctx, "ManagementGetProviderApiLimitCount", req, &reply) return } func (a *GdManagementXClient) MangementGetUserMerchantCountCode(ctx context.Context, req *MangementGetUserMerchantCountCodeReq) (reply MangementGetUserMerchantCountCodeReply, err error) { err = a.xcli.Call(ctx, "MangementGetUserMerchantCountCode", req, &reply) return } func (a *GdManagementXClient) ManagementGetProviderCountInfo(ctx context.Context, req *ManagementGetProviderCountInfoReq) (reply ManagementGetProviderCountInfoReply, err error) { err = a.xcli.Call(ctx, "ManagementGetProviderCountInfo", req, &reply) return } func (a *GdManagementXClient) ManagementGetApiShowInfo(ctx context.Context, req *ManagementGetApiShowInfoReq) (reply ManagementGetApiShowInfoReply, err error) { err = a.xcli.Call(ctx, "ManagementGetApiShowInfo", req, &reply) return } func (a *GdManagementXClient) ManagementGetMerchantApiTimeout(ctx context.Context, req *ManagementGetMerchantApiTimeoutReq) (reply ManagementGetMerchantApiTimeoutReply, err error) { err = a.xcli.Call(ctx, "ManagementGetMerchantApiTimeout", req, &reply) return }