Make SkipDetect more generic as stack::MakeSwitch#657
Conversation
SkipDetect is needlessly coupled to its `listen::Addrs` target type and the Accept stack's shape. In reality, it's pretty similar to the fallback module, except that decisions are made on the target rather than the response future. This change replaces the `core::proxy::skip_detct` module with `stack::switch`. Above all, this allows us to use other targets with this module, which is needed to do discovery before protoocl detection (and to use the results of discovery to inform detection).
hawkw
left a comment
There was a problem hiding this comment.
this looks good to me, and the change is really quite simple...i had some dumb naming bikesheds, feel free to disregard them
| @@ -0,0 +1,84 @@ | |||
| //! A middleware that switches between two underlying stacks, depending on the | |||
| //! target type. | |||
There was a problem hiding this comment.
nit: it's really the target value, not the target type --- the type is the same for both stacks...
| /// Determines whether the primary stack should be used. | ||
| pub trait Switch<T> { | ||
| fn use_primary(&self, target: &T) -> bool; | ||
| } | ||
|
|
||
| /// Makes either the primary or fallback stack, as determined by an `S`-typed | ||
| /// `Switch`. | ||
| pub struct MakeSwitch<S, P, F> { |
There was a problem hiding this comment.
Some part of me wants to push harder on unifying terminology between this and the existing fallback stuff --- what we've really implemented here is sort of a FallbackOnTarget and FallbackOnError. but, it doesn't super matter.
| /// Determines whether the primary stack should be used. | ||
| pub trait Switch<T> { | ||
| fn use_primary(&self, target: &T) -> bool; | ||
| } | ||
|
|
||
| /// Makes either the primary or fallback stack, as determined by an `S`-typed | ||
| /// `Switch`. | ||
| pub struct MakeSwitch<S, P, F> { |
There was a problem hiding this comment.
nit: not sold on calling this MakeSwitch, since it would work equally well at the Service/Request level as well as the MakeService/Target level...names starting with Make kinda suggest to me that this only ever has a Service response type. Maybe the service should be Switch and the trait `Predicate or something?
|
Can address naming in a followup, but want to get this merged |
This release fixes a recent regression in multicluster gateway configurations that would forbid inbound gateway traffic. It also fixes URI normalization for orig-proto-upgrade requests that do not include a `Host` header. --- * http: Simplify stacks and target types (linkerd/linkerd2-proxy#656) * Make SkipDetect more generic as stack::MakeSwitch (linkerd/linkerd2-proxy#657) * introduce tests for isolated services (linkerd/linkerd2-proxy#655) * http: Put normalize_uri back on the stack (linkerd/linkerd2-proxy#659) * inbound: Apply loop detection on the connect stack (linkerd/linkerd2-proxy#660) * tracing: Elide redundant info in tracing contexts (linkerd/linkerd2-proxy#661) * outbound: Reorganize outbound stacks (linkerd/linkerd2-proxy#662) * app: Decouple stacks from listeners (linkerd/linkerd2-proxy#663) * inbound: Split HTTP detection stack from TLS (linkerd/linkerd2-proxy#664) * integration: Bundle tests in src (linkerd/linkerd2-proxy#665)
This release fixes a recent regression in multicluster gateway configurations that would forbid inbound gateway traffic. It also fixes URI normalization for orig-proto-upgrade requests that do not include a `Host` header. --- * http: Simplify stacks and target types (linkerd/linkerd2-proxy#656) * Make SkipDetect more generic as stack::MakeSwitch (linkerd/linkerd2-proxy#657) * introduce tests for isolated services (linkerd/linkerd2-proxy#655) * http: Put normalize_uri back on the stack (linkerd/linkerd2-proxy#659) * inbound: Apply loop detection on the connect stack (linkerd/linkerd2-proxy#660) * tracing: Elide redundant info in tracing contexts (linkerd/linkerd2-proxy#661) * outbound: Reorganize outbound stacks (linkerd/linkerd2-proxy#662) * app: Decouple stacks from listeners (linkerd/linkerd2-proxy#663) * inbound: Split HTTP detection stack from TLS (linkerd/linkerd2-proxy#664) * integration: Bundle tests in src (linkerd/linkerd2-proxy#665)
SkipDetect is needlessly coupled to its
listen::Addrstarget type andthe Accept stack's shape. In reality, it's pretty similar to the
fallback module, except that decisions are made on the target rather
than the response future.
This change replaces the
core::proxy::skip_detctmodule withstack::switch.Above all, this allows us to use other targets with this module, which
is needed to do discovery before protoocl detection (and to use the
results of discovery to inform detection).