Skip to content

Commit

Permalink
DialV2: add support for custom timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
fialhopm committed Jan 25, 2024
1 parent 0b0a4ac commit 8b15be4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,24 @@ func Dial(_ context.Context, addr string) (SessionlessTransport, error) {
// functionality. Note v4 is preferred to v6 if a hostname is passed returning
// both A and AAAA records.
func DialV2(addr string) (*V2SessionlessTransport, error) {
return DialV2WithCustomTimeout(addr, 1*time.Second)
}

func DialV2WithCustomTimeout(addr string, timeout time.Duration) (*V2SessionlessTransport, error) {
v2ConnectionOpenAttempts.Inc()
t, err := newTransport(addr)
if err != nil {
v2ConnectionOpenFailures.Inc()
return nil, err
}
v2ConnectionsOpen.Inc()
return newV2SessionlessTransport(t), nil
return newV2SessionlessTransport(t, timeout), nil
}

func newV2SessionlessTransport(t transport.Transport) *V2SessionlessTransport {
func newV2SessionlessTransport(t transport.Transport, timeout time.Duration) *V2SessionlessTransport {
return &V2SessionlessTransport{
Transport: t,
V2Sessionless: newV2Sessionless(t, time.Second),
V2Sessionless: newV2Sessionless(t, timeout),
}
}

Expand Down

0 comments on commit 8b15be4

Please sign in to comment.