-
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
Refactor http servers #554
Refactor http servers #554
Conversation
3ca6891
to
323340e
Compare
(Remove a separate connector).
Run phase1 startup actions in a separate thread.
323340e
to
c37525e
Compare
} else { | ||
LOGGER.info("Starting {} failed", name); |
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.
do we need a log line next to an exception?
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.
Well not necessarily. But let me add the service name to the exception message.
} else { | ||
LOGGER.info("Stoppig {} failed", name); |
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.
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: |
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.
Can we break up this method?
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.
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) { |
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.
can we rename handlerFactory if it is not a factory anymore?
try { | ||
return new InetSocketAddress(host, it.port()); | ||
} catch (IllegalArgumentException e) { | ||
return null; |
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.
Can we at least log anything here?
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.
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.
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(); | ||
}); |
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.
If anything in here fails, is the exception being logged?
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.
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.
Remove shutdownLogging mechanism from styx core.
Need to investigate later.
54a59db
to
a38330b
Compare
Rationale
Simplify Styx HTTP server implementation: