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

Routing object lifecycle management #418

Merged
merged 8 commits into from
May 31, 2019

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented May 28, 2019

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 an HttpHandler. It adds a stop lifecycle method. Each routing object implements a RoutingObject and the stop along with it. The default implementation for stop lifecycle method is to do nothing.

@mikkokar mikkokar requested review from kvosper, VivianLopes and dvlato and removed request for kvosper and VivianLopes May 28, 2019 14:05
@@ -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";
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.handler = handler;
this.handler = requireNonNull(handler);


@Override
public CompletableFuture<Void> stop() {
pathPrefixRouter.routes.forEach((route, value) -> value.stop());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@mikkokar mikkokar merged commit 63442c7 into ExpediaGroup:master May 31, 2019
@mikkokar mikkokar deleted the lifecycle-handlers branch May 31, 2019 18:05
dvlato pushed a commit that referenced this pull request Jul 3, 2019
* StyxObjectStore: insert/remove returns any replaced or removed value.
* RoutingObjectHandler: Trigger lifecycle method (stop) for a removed or replaced routing object.
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.

2 participants