-
Notifications
You must be signed in to change notification settings - Fork 79
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
Routing object lifecycle management #418
Conversation
RoutingObjectHandler: Trigger lifecycle method (stop) for a removed or replaced routing object.
71ba3ba
to
3c24a06
Compare
@@ -58,6 +58,7 @@ | |||
private static final String INTERCEPTOR_PIPELINE = "InterceptorPipeline"; | |||
private static final String PROXY_TO_BACKEND = "ProxyToBackend"; | |||
private static final String PATH_PREFIX_ROUTER = "PathPrefixRouter"; | |||
private static final String HOST_PROXY = "HostProxy"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this new field is not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. left there in when moving host proxy related code out. I'll remove this.
RequestTracker tracker = trackRequests ? CurrentRequestTracker.INSTANCE : RequestTracker.NO_OP; | ||
this.handler = new StandardHttpPipeline(interceptors, handler, tracker); | ||
this.handler = handler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.handler = handler; | |
this.handler = requireNonNull(handler); |
|
||
@Override | ||
public CompletableFuture<Void> stop() { | ||
pathPrefixRouter.routes.forEach((route, value) -> value.stop()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pathPrefixRouter.routes.forEach((route, value) -> value.stop()); | |
pathPrefixRouter.routes.forEach((route, routingObject) -> routingObject.stop()); |
@@ -30,7 +30,10 @@ | |||
* Resolves a routing object reference from route database. | |||
*/ | |||
public interface RouteRefLookup { | |||
HttpHandler apply(RoutingObjectReference route); | |||
// Consider modifying this interface to return Optional<RoutingObject>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It was originally a TODO, but then decided to leave it as a normal comment. I'm bit indecisive at the moment.
* StyxObjectStore: insert/remove returns any replaced or removed value. * RoutingObjectHandler: Trigger lifecycle method (stop) for a removed or replaced routing object.
Lifecycle management is needed for cleaning up stateful resources that routing objects may have.
This is necessary for a new
HostProxy
object (under development) for proxying traffic to an individual remote host. It maintains a connection pool which needs shutting after the object is removed.This PR introduces a new
RoutingObject
interface that extends anHttpHandler
. It adds astop
lifecycle method. Each routing object implements aRoutingObject
and thestop
along with it. The default implementation forstop
lifecycle method is to do nothing.