|
@@ -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())
|
|
|
}
|