package gd_auth_check import ( "context" "fmt" "gd_gateway/apis" "runtime" "time" "github.com/smallnest/rpcx/client" "github.com/smallnest/rpcx/protocol" "github.com/smallnest/rpcx/share" ) type GdAuthCheckXClient struct { xcli client.XClient } func (a *GdAuthCheckXClient) 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 *GdAuthCheckXClient) 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 *GdAuthCheckXClient) ManagementCheckApi(ctx context.Context, req *apis.ManagementCheckApiReq) (reply apis.ManagementCheckApiReply, err error) { err = a.xcli.Call(ctx, "ManagementCheckApi", req, &reply) return } func (a *GdAuthCheckXClient) ManagementThirdpartCountIncrease(ctx context.Context, req *apis.ManagementThirdpartCountIncreaseReq) (reply apis.ManagementThirdpartCountIncreaseReply, err error) { err = a.xcli.Call(ctx, "ManagementThirdpartCountIncrease", req, &reply) return } func (a *GdAuthCheckXClient) ManagementCheckCountCode(ctx context.Context, req *apis.ManagementCheckCountCodeReq) (reply apis.ManagementCheckCountCodeReply, err error) { err = a.xcli.Call(ctx, "ManagementCheckCountCode", req, &reply) return } func (a *GdAuthCheckXClient) ReleaseToken(ctx context.Context, req *apis.RateLimitToken) (reply apis.RateLimitToken, err error) { err = a.xcli.Call(ctx, "ReleaseToken", req, &reply) return } func (a *GdAuthCheckXClient) MerchantAppLogin(ctx context.Context, req *apis.MerchantAppLoginReq) (reply apis.MerchantAppLoginReply, err error) { err = a.xcli.Call(ctx, "MerchantAppLogin", req, &reply) return }