mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 18:04:58 +01:00
25 lines
471 B
Go
25 lines
471 B
Go
|
package connecter
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/zrepl/zrepl/config"
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
type TCPConnecter struct {
|
||
|
Address string
|
||
|
dialer net.Dialer
|
||
|
}
|
||
|
|
||
|
func TCPConnecterFromConfig(in *config.TCPConnect) (*TCPConnecter, error) {
|
||
|
dialer := net.Dialer{
|
||
|
Timeout: in.DialTimeout,
|
||
|
}
|
||
|
|
||
|
return &TCPConnecter{in.Address, dialer}, nil
|
||
|
}
|
||
|
|
||
|
func (c *TCPConnecter) Connect(dialCtx context.Context) (conn net.Conn, err error) {
|
||
|
return c.dialer.DialContext(dialCtx, "tcp", c.Address)
|
||
|
}
|