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

Graceful client connection shutdown #2192

Open
jeromegn opened this issue Apr 23, 2020 · 1 comment
Open

Graceful client connection shutdown #2192

jeromegn opened this issue Apr 23, 2020 · 1 comment

Comments

@jeromegn
Copy link

We have a use case where we know beforehand if we need to stop sending requests to specific connections within the same client pool. Similarly to how it's possible to gracefully shut down a hyper server connection, it would be useful to be able to gracefully shutdown a specific connection. I was about to create my own pool by using handshake and a VecDeque (or something but this might be best as part of hyper directly.

More precisely, we host virtual machines which can go up, down or restart at any time. We use a custom Service implementation to choose which virtual machine to connect to based on a bunch of criteria (essentially: load balancing). When a controlled shutdown of a virtual machine happens, we're notified ~30 seconds or so before it actually happens. At that time, we'd like to make a best effort attempt at gracefully shutting down the connection in such a way that a client stops using it to send requests.

You hinted that it would be possible to do this with a Service? I think the missing bit might just be a way to mark a connection as "shutting down" so hyper knows to stop sending requests to it.

@jeromegn
Copy link
Author

I started using a Service that fulfills MakeConnection and I think that might be the way forward!

However, I've found an issue where there are no Extensions one the resulting Response. I assume that's because it's not making use of the Connection trait which the abstracted Client does use.

I don't think I'd be able to make a custom client::service::Connect to fix that because I'd need access to Connected#set to set the connection extras to the response's extensions.

Any ideas? Sounds like it might require a hyper change.

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

No branches or pull requests

1 participant