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

Handle backpressure and remove ExitReceiver #117

Merged
merged 3 commits into from
Feb 28, 2020

Commits on Feb 28, 2020

  1. Return Err from poll_ready() if stopped

    According to the [docs] for `tower_service::Service::poll_ready()`, the
    method implementation is supposed to return `Poll::Ready(Err(_))` if the
    service in question is no longer able to accept requests. In our current
    implementation, we return `Poll::Pending`, which is semantically
    incorrect.
    
    [docs]: https://docs.rs/tower-service/0.3.0/tower_service/trait.Service.html#tymethod.poll_ready
    
    This changes our `poll_ready()` implementation to conform with the
    upstream interface specification so we can properly handle backpressure.
    ebkalderon committed Feb 28, 2020
    Configuration menu
    Copy the full SHA
    af4f308 View commit details
    Browse the repository at this point in the history
  2. Gracefully shut down once poll_ready() returns Err

    This adapts `Server` to properly handle service backpressure by awaiting
    on `Service::poll_ready()` and exiting early if the underlying service
    returns `Poll::Ready(Err(_))`. This should make the `Server` shut itself
    down gracefully once it detects that the underlying service is no longer
    able to serve requests.
    ebkalderon committed Feb 28, 2020
    Configuration menu
    Copy the full SHA
    08cc0ac View commit details
    Browse the repository at this point in the history
  3. Remove ExitReceiver and LspService::close_handle()

    A nice side effect of the previous `poll_ready()` changes: since the
    `Server` now shuts itself automatically as soon as the underlying
    service returns a `Poll::Ready(Err(_))`, there is no reason to keep
    `ExitReceiver` around anymore.
    
    This allows users to await the `Server::serve()` future directly, which
    improves the API ergonomics quite a bit and allows us to get rid of
    `ExitReceiver` entirely.
    ebkalderon committed Feb 28, 2020
    Configuration menu
    Copy the full SHA
    941e9a7 View commit details
    Browse the repository at this point in the history