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

Refactor http servers #554

Merged
merged 14 commits into from
Dec 12, 2019
Merged

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Dec 5, 2019

Rationale

Simplify Styx HTTP server implementation:

  • Allow only one "connector" for each HTTP server (port).
  • Remove unnecessary builders.
  • Move plugin loading and initialisation into a separate class.
  • Move data plane handler creation and move it into Styx Server.
  • Create separate Netty HTTP servers for HTTP and HTTPS endpoints.

@mikkokar mikkokar force-pushed the refactor-http-servers branch from 3ca6891 to 323340e Compare December 11, 2019 12:10
@mikkokar mikkokar force-pushed the refactor-http-servers branch from 323340e to c37525e Compare December 11, 2019 17:13
@mikkokar mikkokar marked this pull request as ready for review December 12, 2019 09:25
} else {
LOGGER.info("Starting {} failed", name);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a log line next to an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well not necessarily. But let me add the service name to the exception message.

} else {
LOGGER.info("Stoppig {} failed", name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Maybe we can unify the stopping failed message with the exception.

components.nettySocketChannelClass())
.create();

// Startup phase 1: start plugins, control plane providers, and other services:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we break up this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, because this is in a constructor, and assigning to final variables.
But I will be returning to this soon. Expect more changes, but in separate increments.

}

private LiveHttpResponse.Transformer addInfoHeader(LiveHttpResponse.Transformer responseBuilder, LiveHttpRequest request) {
return responseBuilder.header(styxInfoHeaderName, responseInfoFormat.format(request));
}

public ProxyServerBuilder handlerFactory(Supplier<HttpHandler> handlerFactory) {
this.handlerFactory = handlerFactory;
public ProxyServerBuilder handler(HttpHandler handlerFactory) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename handlerFactory if it is not a factory anymore?

try {
return new InetSocketAddress(host, it.port());
} catch (IllegalArgumentException e) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we at least log anything here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.

This is not necessarily an erroneous situation. NettyServer is a stateful object. Returning null implies the server is shut (or not started). Whether or not this is acceptable depends on caller's use case. Logging a message therefore needs to take place at call site.

Comment on lines 268 to 275
CompletableFuture.runAsync(() -> {
// doStart should return quicly. Therefore offload waiting on a separate thread:
this.phase1Services.addListener(new Phase1ServerStartListener(this));
this.phase1Services.startAsync().awaitHealthy();

this.phase2Services.addListener(new ServerStartListener(this));
this.phase2Services.startAsync();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

If anything in here fails, is the exception being logged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made some changes to log them from StyxServer logger.

Sadly the shutdownLogging mechanism (see in StyxServer.java) prevents the tests from working correctly. I need to look into removing this in near future.

@mikkokar mikkokar force-pushed the refactor-http-servers branch from 54a59db to a38330b Compare December 12, 2019 16:31
@mikkokar mikkokar merged commit cdea3a4 into ExpediaGroup:master Dec 12, 2019
@mikkokar mikkokar deleted the refactor-http-servers branch December 12, 2019 16:46
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.

4 participants