Unify dialer implementations
Instead of having several dialer implementations, leave only one in `pkg/dialer` and call it from `pkg/ttrpcutil`, `runtime/v(1|2)/shim` which had their own Closes #3471. Signed-off-by: Kiril Vladimiroff <kiril@vladimiroff.org>
This commit is contained in:
@@ -40,6 +40,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/events"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/pkg/dialer"
|
||||
v1 "github.com/containerd/containerd/runtime/v1"
|
||||
"github.com/containerd/containerd/runtime/v1/shim"
|
||||
shimapi "github.com/containerd/containerd/runtime/v1/shim/v1"
|
||||
@@ -228,7 +229,7 @@ func connect(address string, d func(string, time.Duration) (net.Conn, error)) (n
|
||||
|
||||
func annonDialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||
address = strings.TrimPrefix(address, "unix://")
|
||||
return net.DialTimeout("unix", "\x00"+address, timeout)
|
||||
return dialer.Dialer("\x00"+address, timeout)
|
||||
}
|
||||
|
||||
// WithConnect connects to an existing shim
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/pkg/dialer"
|
||||
"github.com/containerd/containerd/sys"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -75,7 +76,7 @@ func SocketAddress(ctx context.Context, id string) (string, error) {
|
||||
// AnonDialer returns a dialer for an abstract socket
|
||||
func AnonDialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||
address = strings.TrimPrefix(address, "unix://")
|
||||
return net.DialTimeout("unix", "\x00"+address, timeout)
|
||||
return dialer.Dialer("\x00"+address, timeout)
|
||||
}
|
||||
|
||||
func AnonReconnectDialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||
|
||||
Reference in New Issue
Block a user