mirror of
https://github.com/zrepl/zrepl.git
synced 2025-06-20 09:47:50 +02:00
transport/local: hard fail, more aggressive connect timeout
This commit is contained in:
parent
7ba3ae077f
commit
2cd9173bfb
@ -3,6 +3,7 @@ package local
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/zrepl/zrepl/config"
|
"github.com/zrepl/zrepl/config"
|
||||||
"github.com/zrepl/zrepl/transport"
|
"github.com/zrepl/zrepl/transport"
|
||||||
@ -25,5 +26,11 @@ func LocalConnecterFromConfig(in *config.LocalConnect) (*LocalConnecter, error)
|
|||||||
|
|
||||||
func (c *LocalConnecter) Connect(dialCtx context.Context) (transport.Wire, error) {
|
func (c *LocalConnecter) Connect(dialCtx context.Context) (transport.Wire, error) {
|
||||||
l := GetLocalListener(c.listenerName)
|
l := GetLocalListener(c.listenerName)
|
||||||
return l.Connect(dialCtx, c.clientIdentity)
|
dialCtx, cancel := context.WithTimeout(dialCtx, 1*time.Second) // fail fast, config error by user is very likely
|
||||||
|
defer cancel()
|
||||||
|
w, err := l.Connect(dialCtx, c.clientIdentity)
|
||||||
|
if err == context.DeadlineExceeded {
|
||||||
|
return nil, fmt.Errorf("local listener %q not reachable", c.listenerName)
|
||||||
|
}
|
||||||
|
return w, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user