using ContextDialer instead
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)
}
