yjp 11 сар өмнө
parent
commit
4d7a233356

+ 2 - 16
grpc_client/grpc_client.go

@@ -5,16 +5,14 @@ import (
 	"git.sxidc.com/service-supports/ds-sdk/grpc_client/v1"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/credentials/insecure"
-	"time"
 )
 
 type Client struct {
 	conn         *grpc.ClientConn
 	sqlServiceV1 v1.SqlServiceClient
-	timeout      time.Duration
 }
 
-func NewClient(address string, timeout time.Duration) (*Client, error) {
+func NewClient(address string) (*Client, error) {
 	conn, err := grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		return nil, err
@@ -23,7 +21,6 @@ func NewClient(address string, timeout time.Duration) (*Client, error) {
 	return &Client{
 		conn:         conn,
 		sqlServiceV1: v1.NewSqlServiceClient(conn),
-		timeout:      timeout,
 	}, nil
 }
 
@@ -45,16 +42,5 @@ func Destroy(c *Client) error {
 }
 
 func (c *Client) Transaction() (v1.SqlService_TransactionClient, error) {
-	var ctx context.Context
-
-	if c.timeout == 0 {
-		ctx = context.Background()
-	} else {
-		timeoutCtx, cancel := context.WithTimeout(context.Background(), c.timeout)
-		defer cancel()
-
-		ctx = timeoutCtx
-	}
-
-	return c.sqlServiceV1.Transaction(ctx)
+	return c.sqlServiceV1.Transaction(context.Background())
 }

+ 1 - 1
sdk/instance.go

@@ -30,7 +30,7 @@ func InitInstance(token string, address string, httpPort string, grpcPort string
 
 	c := client.New(options.timeout)
 
-	grpcClient, err := grpc_client.NewClient(options.grpcAddress, options.timeout)
+	grpcClient, err := grpc_client.NewClient(options.grpcAddress)
 	if err != nil {
 		return err
 	}