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
http conn manager: Support Route Mutability #14904
Comments
Note I already discussed this with the Lyft team internally. +1 from me. This has been asked for previously, is easy to implement, and will allow filters to fully customize route selection easily. cc @alyssawilk @snowp for thoughts. |
In general very much in favor of this, just a few immediate thoughts: I imagine this would not survive a Would you also be adding a delegating I think another option would be to expose mutating functions on the Route/RouteEntry, allowing for it to be modified directly instead of having to decorate it with a wrapper object to override values. That said, the wrapper allows for more flexibility without code changes (we avoid changes for each thing on the route we want to change), so it seems like a good direction. Overall I think this is good, this would have been very helpful for me in the past, where I've jumped through similar hoops to update the final route. |
Definitely a fan of 1) |
Thanks for the feedback everyone! @mattklein123 Saw you added the "help wanted" tag, to clarify I'll be taking on this implementation work :) @snowp Correct, this wouldn't survive a Yes, the plan is to also add a @alyssawilk Yes that is exactly the plan for (2)! For now, my plan was just to enable overriding the route entry (as Snow pointed out, I'll be adding a |
@mattklein123 @snowp With #15266 merged, can we close this issue now? |
Thank you! |
Title: StreamFilter: Support Route Mutability
Description:
At Lyft we have a
Http::StreamDecoderFilter
that goes through rewriting theHost:
header, clearing the route cache, and having the HTTP connection manager reevaluate the route selection -- just to update therouteEntry
clusterName of a route (aRouter::RouteConstSharedPtr
). There is no support for route mutability.Proposing two changes to enable a filter to directly mutate properties of a route, rather than having to go through the roundabout process of rewriting headers & clearing the route cache.
Proposal:
setRoute(const Router::RouteConstSharedPtr route)
method to the StreamFilter API (in StreamFilterCallbacks) that sets the current request’s route as the passed-inRouteConstSharedPtr
argument.DelegatingRoute
, which implements its base/parent class ofRouter:Route
by delegating all method calls to the baseRoute that it wraps around.DelegatingRoute
will take in a baseRoute (aRouteConstSharedPtr
) in its constructor, and calls to Route class methods such asdirectResponseEntry
androuteEntry
will simply get delegated to the baseRoute.Rationale for 2:
As part of enabling route mutability, the goal is to build a mechanism that enables developers to easily take an existing route, and create a new route that mutates specific properties (In our case,
routeEntry
, but another example can betracingConfig
) while preserving all the rest of the properties/behavior of the existing route. We introduce the concept of aDelegatingRoute
as this mechanism. An alternative approach, deep copying an existing route, is prohibitively expensive.Usage:
Usage would be a filter calling
setRoute(r)
wherer
is a derived/child class ofDelegatingRoute
. In addition,DelegatingRoute
will be useful in unit testing (will be used to test Lyft’s new filter modifying clusterName) for any changes related to modifying a route.The text was updated successfully, but these errors were encountered: