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

RetryPolicy refactor suggestions #1045

Merged
merged 3 commits into from
Jun 14, 2021

Conversation

olix0r
Copy link
Member

@olix0r olix0r commented Jun 14, 2021

A few suggestions on #1043

  • Expose EraseRequest via BoxRequest::erased -- we don't actually care about the different types--the behavior is basically the same -- there's just some minor differences with regards to preserving marker types. It reads a little bit more naturally if we just hang it all off BoxRequest.
  • Renamed the linkerd_retry::RetryPolicy trait to linkerd_retry::PrepareRequest (to match its only method). It's a bit... malkovich to have both tower::retry::Policy and linkerd_retry::RetryPolicy which are closely related but different.
  • linkerd_retry now re-exports relevant tower::retry types.
  • Renames in app::core::retry to reflect actual types. For instance, NewRetry is now NewRetryPolicy -- since it actually implements NewPolicy and has nothing to do with the retry::NewRetry type.
  • NewRetryLayer eliminated in favor of an anonymous type.
  • Various inlines on pass-through service/proxy methods

@olix0r olix0r requested review from hawkw and a team June 14, 2021 17:49
Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

lgtm, i'm on board with all these suggestions! i did leave a comment on the trait naming thing explaining my original thought process, but i'm not attached to it at all --- this is probably better. other than that, nothing stood out, thanks!

Comment on lines +21 to +24
/// Constructs a boxing layer that erases the inner request type with [`EraseRequest`].
pub fn erased() -> impl layer::Layer<S, Service = EraseRequest<S>> + Clone + Copy {
EraseRequest::layer()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

/// An extension to [`tower::retry::Policy`] that adds a method to prepare a
/// request to be retried, possibly changing its type.
pub trait RetryPolicy<Req, Res, E>: tower::retry::Policy<Self::RetryRequest, Res, E> {
pub trait PrepareRequest<Req, Res, E>: tower::retry::Policy<Self::RetryRequest, Res, E> {
Copy link
Contributor

Choose a reason for hiding this comment

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

my original motivation for naming this RetryPolicy --- which i agree is a bit confusing --- was because it requires tower's RetryPolicy trait, so when it's used, we only bound the type with this trait.

i also considered the name PrepareRequest, but it seemed kind of weird to me to require that the policy implement PrepareRequest and not mention that it is also a retry policy? maybe that's not actually worth worrying about, and i'm fine with this naming scheme if you think it's clearer...

Copy link
Member Author

Choose a reason for hiding this comment

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

could call it PreparePolicy or something like that -- but RetryPolicy vs Policy is a bit too subtle imo

@olix0r olix0r merged commit 712c2a4 into eliza/cap-replay-body Jun 14, 2021
@olix0r olix0r deleted the ver/eliza/cap-replay-body branch June 14, 2021 19:01
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.

2 participants