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

Respect context cancellation and deadlines. #671

Merged
merged 6 commits into from
Jul 19, 2021
Merged

Respect context cancellation and deadlines. #671

merged 6 commits into from
Jul 19, 2021

Conversation

favonia
Copy link
Contributor

@favonia favonia commented Jul 17, 2021

Description

The backoff during retries should have checked the deadline/timeout set by context.

Has your change been tested?

Two regression tests were added, though they are not very robust. The 2s and .5s 1s thresholds to detect whether the library is honoring the deadlines are in a sense arbitrary.

Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@favonia favonia marked this pull request as draft July 17, 2021 05:01
@favonia
Copy link
Contributor Author

favonia commented Jul 17, 2021

The linting error reported by golangci-lint was about this expression:

0x1 << uint8(math.Ceil(float64(i/2)))

I did not write it and it's orthogonal to this PR. Therefore, I would like to hear from the maintainers what to do before fixing it.

@favonia favonia marked this pull request as ready for review July 17, 2021 06:08
cloudflare.go Outdated Show resolved Hide resolved
There are two possibilities: either the context was cancelled or the
deadline exceeded.
@favonia favonia changed the title Respect the deadline set by context. Respect context cancellation and deadlines. Jul 18, 2021
@jacobbednarz
Copy link
Member

The linting error reported by golangci-lint was about this expression:

0x1 << uint8(math.Ceil(float64(i/2)))

golangci-lint would have picked this up as the line itself was edited in this PR. as the fix is just removing the math.Ceil function, i think we can get rid of that safely in this PR.

jacobbednarz and others added 3 commits July 19, 2021 12:58
PS: The threshold cannot be longer than 1s; otherwise it is not failing
the old (wrong) code.
@favonia
Copy link
Contributor Author

favonia commented Jul 19, 2021

The linting error reported by golangci-lint was about this expression:
0x1 << uint8(math.Ceil(float64(i/2)))

golangci-lint would have picked this up as the line itself was edited in this PR. as the fix is just removing the math.Ceil function, i think we can get rid of that safely in this PR.

Got it. I tried to simplify the expression further.

@jacobbednarz
Copy link
Member

LGTM, thanks! 🥳

@jacobbednarz jacobbednarz merged commit a6793ca into cloudflare:master Jul 19, 2021
@favonia favonia deleted the respect-context-timeout branch July 19, 2021 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants