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

filter: add get_ref, get_mut, and into_inner #522

Merged
merged 1 commit into from
Jan 11, 2021
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Jan 11, 2021

This branch adds methods to access the inner service of a Filter or an
AsyncFilter. These are identical to the similarly-named method
provided by many other middleware services.

Along with the changes in #521, this is also necessary to implement
filtered versions of foreign traits in downstream code. I probably
should've added this in that PR, but I wasn't thinking it through...

This branch adds methods to access the inner service of a `Filter` or an
`AsyncFilter`. These are identical to the similarly-named method
provided by many other middleware services.

Along with the changes in #521, this is also necessary to implement
filtered versions of foreign traits in downstream code. I probably
should've added this in that PR, but I wasn't thinking it through...
@hawkw hawkw self-assigned this Jan 11, 2021
@hawkw hawkw merged commit b4169c7 into master Jan 11, 2021
@hawkw hawkw deleted the eliza/filter-inner branch January 11, 2021 23:19
olix0r pushed a commit to linkerd/linkerd2-proxy that referenced this pull request Jan 14, 2021
Tower provides a `tower::filter` utility for conditionally rejecting
some requests and accepting others. Rather than using `tower`'s filter,
we have a similar `linkerd_stack::request_filter`, due to two main
issues with the filtering API in tower 0.3 and earlier:

* `tower::filter`'s predicates returned futures, which we don't need
  --- all our filtering predicates are purely sunchronous
* `tower::filter` didn't allow filters to return any error of their
  choosing --- they had to return a specific filter-rejected error.
  This doesn't work with other code where we downcast error types,
  like switch/fallback.

However, Tower 0.4 includes a rewritten `Filter` API that no longer
has these issues (tower-rs/tower#508). Therefore, we can switch to
using the upstream implementation. This branch replaces `RequestFilter`
with `tower::filter::Filter`.

It was necessary to add an impl of `NewService` for `Filter`. This
required an upstream change to expose access to the wrapped service,
so that its `new_service` method can be called when it's a
`NewService`, and to expose access to the `Predicate`. Therefore, this
PR depends on tower-rs/tower#521 and tower-rs/tower#522, and introduces
a Git dependency. The git dep can be removed when Tower 0.4.3 is
released.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
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

2 participants