Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

feat: pass Retry-After to end user #56

Merged
merged 4 commits into from
Mar 8, 2023

Conversation

lidel
Copy link
Collaborator

@lidel lidel commented Mar 6, 2023

This PR aims to use cooldown and seturn it in Retry-After header to the client.

Based on ipfs/boxo#194

@lidel lidel requested a review from hacdias March 6, 2023 03:48
Comment on lines +73 to +74
if errors.Is(err, &gateway.ErrorResponse{}) ||
errors.Is(err, &gateway.ErrorRetryAfter{}) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ this removes the need for listing every error code

blockstore.go Outdated Show resolved Hide resolved
@lidel lidel marked this pull request as ready for review March 6, 2023 04:04
Copy link
Collaborator

@hacdias hacdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's wait for filecoin-saturn/caboose#60.

@hacdias hacdias force-pushed the feat/pass-http-retry-after-header branch from 87ef286 to 476ffb6 Compare March 8, 2023 09:42
Comment on lines +87 to +94
// (Saturn) errors that support the RetryAfter interface need to be converted
// to the correct gateway error, such that the HTTP header is set.
for v := err; v != nil; v = errors.Unwrap(v) {
if r, ok := v.(interface{ RetryAfter() time.Duration }); ok {
return gateway.NewErrorRetryAfter(err, r.RetryAfter())
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very hacky, but I love it. Now we support all errors that export the RetryAfter() time.Duration interface.

@hacdias
Copy link
Collaborator

hacdias commented Mar 8, 2023

I added a test so I am confident that the conversion works. I will merge once CI is green.

@hacdias hacdias merged commit 2dc2c03 into main Mar 8, 2023
@hacdias hacdias deleted the feat/pass-http-retry-after-header branch March 8, 2023 10:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants