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

Coroutinize http client code #2429

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Commits on Sep 12, 2024

  1. http/client: Coroutinize connection::write_body

    And brush up the if-else nesting a little bit to avoid co_return-s
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    797dc34 View commit details
    Browse the repository at this point in the history
  2. http/client: Coroutinize connection::maybe_wait_for_continue

    For simplicity, wrap the entrance `if` around.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    32365d4 View commit details
    Browse the repository at this point in the history
  3. http/client: Coroutinize connection::send_request_head

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    e8df44b View commit details
    Browse the repository at this point in the history
  4. http/client: Coroutinize connection::recv_reply

    And leave indentation broken until next patch
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    dd51c2c View commit details
    Browse the repository at this point in the history
  5. http/client: Restore indentation of connection::recv_reply

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    ad9833d View commit details
    Browse the repository at this point in the history
  6. http/client: Coroutinize connection::do_make_request

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    9b46ea5 View commit details
    Browse the repository at this point in the history
  7. http/client: Restore indentation of connection::do_make_request

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    86d6a8b View commit details
    Browse the repository at this point in the history
  8. http/client: Squash maybe_wait_for_continue into do_make_request

    The former helper was introduced to reduce the netsing of .then-chains.
    Now when it's a coroutinie, it's better be squashed with its only
    caller.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    14e3efc View commit details
    Browse the repository at this point in the history
  9. http/client Squash send_request_head into do_make_request

    Same as previous patch -- the former method was a way to reduce
    indentation level for the latter. Now they look good enough when
    squashed.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    c5a63be View commit details
    Browse the repository at this point in the history
  10. http/client: Coroutinize connection::make_request

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    9b473bf View commit details
    Browse the repository at this point in the history
  11. http/client: Coroutinize connection::close

    There's a trickery there. After _closed future is resolved "this" may
    become freed already. So to make the last log message printed, the
    this->local_address was saved into .then capture. When coroutinized,
    that field is kept on stack.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    ffacf24 View commit details
    Browse the repository at this point in the history
  12. http/client: Restore indentation of connection::close

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    cb1b4b6 View commit details
    Browse the repository at this point in the history
  13. http/client: Coroutinize client::make_connection

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    bd36cf3 View commit details
    Browse the repository at this point in the history
  14. http/client: Restore indentation of client::make_connection

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    bdfdf16 View commit details
    Browse the repository at this point in the history
  15. http/client: Coroutinize client::put_connection

    There's a trickery here. After con->close() is resolved, the con may be
    the last pointer holding the connection alive. Before this patch, it was
    saved on .finally capture, after it -- it's preserved as on-stack
    variable.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    2d1550e View commit details
    Browse the repository at this point in the history
  16. http/client: Coroutinize client::shrink_connections

    In its .then-chain form the method calls itself to emulate "goto again"
    without goto. To do the same with coroutines, wrap it into a loop.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    215e024 View commit details
    Browse the repository at this point in the history
  17. http/client: Restore indentation of client::shrink_connections

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    88de135 View commit details
    Browse the repository at this point in the history
  18. http/client: Coroutinize client::set_maximum_connections

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    b10c8b6 View commit details
    Browse the repository at this point in the history
  19. http/client: Coroutinize client::with_connection

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    685f6f2 View commit details
    Browse the repository at this point in the history
  20. http/client: Coroutinize client::with_new_connection

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    200ea10 View commit details
    Browse the repository at this point in the history
  21. http/client: Coroutinize client::close

    This method closes all its connection by calling itself until the pool
    is empty. With coroutines it is done with the plain loop.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    4250bca View commit details
    Browse the repository at this point in the history
  22. http/client: Restore indentation of client::close

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    688ac04 View commit details
    Browse the repository at this point in the history
  23. http/client: Coroutinize client::do_make_request

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    3e22a25 View commit details
    Browse the repository at this point in the history
  24. http/client: Sanitize client::do_make_request unexpected body logging

    When reply contains unexpected status, client may print its body in
    logs. Before being coroutinized it was two disctinct chains, with
    coroutines it makes sense to rewrap them a little bit.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    02df7b8 View commit details
    Browse the repository at this point in the history
  25. http/client: Coroutinize client::get_connection

    It used to call itself to "goto again". With coroutines it won't work as
    nice, neither it looks good enough with the outer loop :( So use goto
    explicitly.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    4dfb090 View commit details
    Browse the repository at this point in the history
  26. http/client: Restore indentation of client::get_connection

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    539fa2a View commit details
    Browse the repository at this point in the history
  27. http/client: Coroutinize client::do_make_request (con-less overload)

    It makes some non-trivial decisions on whether or to retry the request
    in the catch block, so the conversion is a bit hairy.
    
    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    3231966 View commit details
    Browse the repository at this point in the history
  28. http/client: Restore indentation of client::do_make_request overload

    Signed-off-by: Pavel Emelyanov <[email protected]>
    xemul committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    67134fd View commit details
    Browse the repository at this point in the history