-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Title: StreamFilter: Support Route Mutability
Description:
At Lyft we have a Http::StreamDecoderFilter that goes through rewriting the Host: header, clearing the route cache, and having the HTTP connection manager reevaluate the route selection -- just to update the routeEntry clusterName of a route (a Router::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:
- Add a new
setRoute(const Router::RouteConstSharedPtr route)method to the StreamFilter API (in StreamFilterCallbacks) that sets the current request’s route as the passed-inRouteConstSharedPtrargument. - Add a new class called
DelegatingRoute, which implements its base/parent class ofRouter:Routeby delegating all method calls to the baseRoute that it wraps around.DelegatingRoutewill take in a baseRoute (aRouteConstSharedPtr) in its constructor, and calls to Route class methods such asdirectResponseEntryandrouteEntrywill 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 be tracingConfig ) while preserving all the rest of the properties/behavior of the existing route. We introduce the concept of a DelegatingRoute as this mechanism. An alternative approach, deep copying an existing route, is prohibitively expensive.
Usage:
Usage would be a filter calling setRoute(r) where r is a derived/child class of DelegatingRoute. 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.