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

refactor: extract retry quota into a tower service #2172

Closed
wants to merge 5 commits into from

Conversation

Velfi
Copy link
Contributor

@Velfi Velfi commented Jan 5, 2023

Motivation and Context

#1785

Description

This PR extracts the retry quota state from the RetryHandler and places it in its own tower::Layer. This is a first step in the process to introduce adaptive retry behavior which will use its own specialized retry quota layer.

Testing

Ran existing tests

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Velfi Velfi requested a review from a team as a code owner January 5, 2023 21:35
Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

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

Looks awesome! Excited about these changes 👍

rust-runtime/aws-smithy-client/src/quota.rs Outdated Show resolved Hide resolved
rust-runtime/aws-smithy-client/src/retry/adaptive.rs Outdated Show resolved Hide resolved
rust-runtime/aws-smithy-client/src/retry/adaptive.rs Outdated Show resolved Hide resolved

#[test]
fn retry_handler_send_sync() {
fn must_be_send_sync<T: Send + Sync>() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is cool. I know there is a crate out there called static-assertions, but what we have here will do.

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

A new generated diff is ready to view.

A new doc preview is ready to view.

Comment on lines 119 to 121
if self.state.available() == 0 {
// If no quota is available, report pending
Poll::Pending
Copy link
Collaborator

Choose a reason for hiding this comment

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

this won't quite work—we need to schedule a wakeup when state goes back above 0. As written, if state goes to 0, that task will never get woken up

@Velfi
Copy link
Contributor Author

Velfi commented Jan 9, 2023

I'm going to focus on implementing the TokenBucket as its own testable thing before finishing up this PR.

@Velfi Velfi marked this pull request as draft January 9, 2023 17:08
add: token bucket
remove: token bucket from retry
@Velfi Velfi force-pushed the refactor/extract-retry-quota-into-tower-service branch from 0556f33 to c6244ec Compare January 11, 2023 19:58
@Velfi Velfi closed this Mar 22, 2023
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.

3 participants