using ContextDialer instead
Signed-off-by: zounengren <zouyee1989@gmail.com>
This commit is contained in:
		| @@ -17,6 +17,7 @@ | |||||||
| package ttrpcutil | package ttrpcutil | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"sync" | 	"sync" | ||||||
| @@ -42,7 +43,9 @@ type Client struct { | |||||||
| // NewClient returns a new containerd TTRPC client that is connected to the containerd instance provided by address | // NewClient returns a new containerd TTRPC client that is connected to the containerd instance provided by address | ||||||
| func NewClient(address string, opts ...ttrpc.ClientOpts) (*Client, error) { | func NewClient(address string, opts ...ttrpc.ClientOpts) (*Client, error) { | ||||||
| 	connector := func() (*ttrpc.Client, error) { | 	connector := func() (*ttrpc.Client, error) { | ||||||
| 		conn, err := dialer.Dialer(address, ttrpcDialTimeout) | 		ctx, cancel := context.WithTimeout(context.Background(), ttrpcDialTimeout) | ||||||
|  | 		defer cancel() | ||||||
|  | 		conn, err := dialer.ContextDialer(ctx, address) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, fmt.Errorf("failed to connect: %w", err) | 			return nil, fmt.Errorf("failed to connect: %w", err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 zounengren
					zounengren