Merge pull request #7189 from zouyee/ctx
This commit is contained in:
commit
badb66113c
@ -17,6 +17,7 @@
|
||||
package ttrpcutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"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
|
||||
func NewClient(address string, opts ...ttrpc.ClientOpts) (*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 {
|
||||
return nil, fmt.Errorf("failed to connect: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user