Commit 7e962b51 authored by Steven Allen's avatar Steven Allen

unexport ReuseErrShouldRetry

There's no reason a consumer of this package would use this error as *we* retry
internally. Exporting it will just confuse users.
parent 397f551c
...@@ -8,10 +8,10 @@ import ( ...@@ -8,10 +8,10 @@ import (
reuseport "github.com/libp2p/go-reuseport" reuseport "github.com/libp2p/go-reuseport"
) )
// ReuseErrShouldRetry diagnoses whether to retry after a reuse error. // reuseErrShouldRetry diagnoses whether to retry after a reuse error.
// if we failed to bind, we should retry. if bind worked and this is a // if we failed to bind, we should retry. if bind worked and this is a
// real dial error (remote end didnt answer) then we should not retry. // real dial error (remote end didnt answer) then we should not retry.
func ReuseErrShouldRetry(err error) bool { func reuseErrShouldRetry(err error) bool {
if err == nil { if err == nil {
return false // hey, it worked! no need to retry. return false // hey, it worked! no need to retry.
} }
...@@ -54,7 +54,7 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) ( ...@@ -54,7 +54,7 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) (
return con, nil return con, nil
} }
if ReuseErrShouldRetry(err) && ctx.Err() == nil { if reuseErrShouldRetry(err) && ctx.Err() == nil {
log.Debugf("failed to reuse port, dialing with a random port: %s", err) log.Debugf("failed to reuse port, dialing with a random port: %s", err)
var d net.Dialer var d net.Dialer
con, err = d.DialContext(ctx, network, raddr) con, err = d.DialContext(ctx, network, raddr)
......
...@@ -40,7 +40,7 @@ func TestReuseError(t *testing.T) { ...@@ -40,7 +40,7 @@ func TestReuseError(t *testing.T) {
} }
for k, v := range cases { for k, v := range cases {
if ReuseErrShouldRetry(k) != v { if reuseErrShouldRetry(k) != v {
t.Fatalf("expected %t for %#v", v, k) t.Fatalf("expected %t for %#v", v, k)
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment