forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
26
pkg/network/dial.go
Normal file
26
pkg/network/dial.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
manet "github.com/multiformats/go-multiaddr-net"
|
||||
)
|
||||
|
||||
// Dial connects to a remote node by address.
|
||||
func Dial(ctx context.Context, addr Address) (net.Conn, error) {
|
||||
return dialContext(ctx, addr, 0)
|
||||
}
|
||||
|
||||
// DialWithTimeout connects to a remote node by address with timeout.
|
||||
func DialWithTimeout(ctx context.Context, addr Address, timeout time.Duration) (net.Conn, error) {
|
||||
return dialContext(ctx, addr, timeout)
|
||||
}
|
||||
|
||||
func dialContext(ctx context.Context, addr Address, timeout time.Duration) (net.Conn, error) {
|
||||
dialer := manet.Dialer{}
|
||||
dialer.Timeout = timeout
|
||||
|
||||
return dialer.DialContext(ctx, addr)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue