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

[BREAKING]: Modernize core server code and improve overall ergonomics #854

Merged
merged 8 commits into from
Jun 19, 2022

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Jun 18, 2022

There have been a few issues (#587, #563) around the overall ergonomics
of using HTTP.listen and the code hasn't had a good comb-through in a while.

I used the core golang server code
as a reference to see what kinds of things they allowed in terms of configuration,
functionality, and overall ergonomics.

The changes proposed here include:

  • New HTTP.listen! non-blocking version of HTTP.listen that returns a Server object
  • Server object supports wait, close, and forceclose; close initiates a "graceful"
    shutdown where active connections are waited for until they are finished being processed;
    forceclose just force closes all open connections.
  • The combination of HTTP.listen! + Server mean we have a much more convenient and simple
    way to interact with a running server.
  • In addition, when calling the provided handler function f, we use Base.invokelatest(f, stream)
    which gives the nice property of allowing Revise to "update" a live server by reflecting edits
    made to the handler/middleware stack.
  • Removed reuse_limit and rate_limit features since they were either problematic in their
    implementation or not really that useful
  • Tried to clean up the verbose logging story, though there's more to do here
  • Tried to clean up some core listenloop logic, though there's more to do here

Otherwise, the core HTTP.listen function remains mostly unchanged, except for the changes to supported
keyword arguments. Still need to update some tests, docs, and comb-through the handle_transaction
function, but wanted to put this up now in case others are interested in taking a look.

There have been a few issues (#587, #563) around the overall ergonomics
of using `HTTP.listen` and the code hasn't had a good comb-through in a while.

I used the core golang [server code](https://github.com/golang/go/blob/master/src/net/http/server.go)
as a reference to see what kinds of things they allowed in terms of configuration,
functionality, and overall ergonomics.

The changes proposed here include:
  * New `HTTP.listen!` non-blocking version of `HTTP.listen` that returns a `Server` object
  * `Server` object supports `wait`, `close`, and `forceclose`; `close` initiates a "graceful"
    shutdown where active connections are waited for until they are finished being processed;
    `forceclose` just force closes all open connections.
  * The combination of `HTTP.listen!` + `Server` mean we have a much more convenient and simple
    way to interact with a running server.
  * In addition, when calling the provided handler function `f`, we use `Base.invokelatest(f, stream)`
    which gives the nice property of allowing Revise to "update" a live server by reflecting edits
    made to the handler/middleware stack.
  * Removed `reuse_limit` and `rate_limit` features since they were either problematic in their
    implementation or not really that useful
  * Tried to clean up the verbose logging story, though there's more to do here
  * Tried to clean up some core listenloop logic, though there's more to do here

Otherwise, the core `HTTP.listen` function remains mostly unchanged, except for the changes to supported
keyword arguments. Still need to update some tests, docs, and comb-through the `handle_transaction`
function, but wanted to put this up now in case others are interested in taking a look.
@quinnj quinnj changed the title Modernize core server code and improve overall ergonomics [BREAKING]: Modernize core server code and improve overall ergonomics Jun 18, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 18, 2022

Codecov Report

Merging #854 (f66e66f) into master (8a7ae8f) will decrease coverage by 0.74%.
The diff coverage is 78.75%.

@@            Coverage Diff             @@
##           master     #854      +/-   ##
==========================================
- Coverage   80.53%   79.78%   -0.75%     
==========================================
  Files          36       36              
  Lines        2825     2849      +24     
==========================================
- Hits         2275     2273       -2     
- Misses        550      576      +26     
Impacted Files Coverage Δ
src/ConnectionPool.jl 88.94% <ø> (ø)
src/Handlers.jl 83.11% <50.00%> (-0.65%) ⬇️
src/WebSockets.jl 87.82% <50.00%> (-0.42%) ⬇️
src/Servers.jl 76.56% <79.35%> (-11.61%) ⬇️
src/Messages.jl 87.42% <100.00%> (ø)
src/clientlayers/StreamRequest.jl 96.61% <0.00%> (-1.70%) ⬇️
src/clientlayers/RetryRequest.jl 76.19% <0.00%> (+2.38%) ⬆️
src/IOExtras.jl 80.00% <0.00%> (+2.85%) ⬆️
... and 1 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@quinnj quinnj merged commit 170725b into master Jun 19, 2022
@quinnj quinnj deleted the jq/serverupdates branch June 19, 2022 06:48
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