Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autoconnect retrial logic being too aggressive #968

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/servicedisc/autoconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
// PublicServiceDelay defines a delay before adding transports to public services.
PublicServiceDelay = 10 * time.Second

fetchServicesDelay = 3 * time.Minute
fetchServicesDelay = 10 * time.Second
maxFailedAddressRetryAttempt = 2
)

Expand Down Expand Up @@ -89,7 +89,7 @@ func (a *autoconnector) Run(ctx context.Context) (err error) {
}

func (a *autoconnector) fetchPubAddresses(ctx context.Context) ([]cipher.PubKey, error) {
retrier := netutil.NewRetrier(fetchServicesDelay, 0, 2)
retrier := netutil.NewRetrier(fetchServicesDelay, 5, 3)
var services []Service
fetch := func() (err error) {
// "return" services up from the closure
Expand Down
5 changes: 5 additions & 0 deletions pkg/servicedisc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func (c *HTTPClient) Services(ctx context.Context, quantity int) (out []Service,
return nil, &hErr
}
err = json.NewDecoder(resp.Body).Decode(&out)

if len(out) == 0 {
return nil, fmt.Errorf("no service of type %s registered", c.entry.Type)
}

return out, err
}

Expand Down