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

Improve http.Client connection handling #1581

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Commits on Nov 17, 2023

  1. Improve http.Client connection handling

    HTTP 1.0 servers close the connection automatically after sending the
    response. We updated the http.Client actor such that the users can use
    the high-level API like making several requests in a row without having
    to worry about reconnects. http.Client will buffer the requests and
    flush the buffer once it (re)connects the socket.
    
    Writing to a closed socket is bad and guaranteed to fail, so the user
    (in this case the http.Client actor) should be notified ASAP before
    making further writes. Rather than using the on_error callback from the
    underlying TCPConnection and TLSConnection actors we raise an exception
    from their write() methods. This implies the calls to write() are
    synchronous, but since we're not waiting on network I/O it should be
    fine?!
    mzagozen committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    1178aa0 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2023

  1. Add more TODOs for limiting auto reconnects

    Add some basic heuristics, like when we create a http.Client the first
    time we obviously connect directly then we expect to run at least one
    query. Maybe we should not reconnect after that (in case of HTTP / 1.0
    or not having persistent in later HTTP versions) until there is a second
    query. Now if we see a second query we can assume "there are multiple
    requests" and thus reconnect directly after the 2nd and subsequent
    requests.
    mzagozen committed Nov 20, 2023
    Configuration menu
    Copy the full SHA
    b632e7e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6f95d97 View commit details
    Browse the repository at this point in the history
  3. Raise ConnectionError when writing to closed socket

    By grouping the socket errors under ConnectionError we can be more
    precise in handling the error in consumers of TCP connection actors.
    mzagozen committed Nov 20, 2023
    Configuration menu
    Copy the full SHA
    268f073 View commit details
    Browse the repository at this point in the history