-
Notifications
You must be signed in to change notification settings - Fork 35
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
Any way to cancel watch? #9
Comments
Right now it blocks until a change happens or until there is a network error of some sort. Being able to cancel it early seems like a good idea. What sort of API do you imagine for it? In the meantime, you could run the watch inside a thread and kill the thread if you need to cancel the watch early. |
The problem is that Rust doesn't provide any reasonable way to kill a thread right now (and probably never will). At least as far as I know. I checked hyper and I couldn't see any support for canceling either so I ran out of ideas. |
A time-out and/or a non-blocking method would be a good start (like mpsc). I assume Hyper supports this. I see you've been asking about time-outs in hyperium/hyper#417, but it appears that client.set_read_timeout() has been added now (https://hyper.rs/hyper/0.8.0/hyper/client/struct.Client.html). I'm guessing that HTTP makes a non-blocking method harder. Would you consider adding a time-out for watches, so that we can then intermittently check whether to terminate in watch threads? |
I'm working on updating this crate to user hyper 0.11, which uses an async model based on futures and tokio. You can cancel a future by simply dropping it (letting it go out of scope). I'll see how this plays out for a watch cancellation API as I get further into it. |
Just so you know, I fully support you spending your free time on this issue, @jimmycuadra! Thank you :-) I don't suppose you have an idea when this work might be available, do you? |
No ETA, but I'll try to make some more progress on this soon! |
I worked on it a bit tonight but it's pretty tough and progress is slow. If you'd like to see what I have so far, take a look at the "async" branch. |
Thanks. I'll probably have to read up on hyper first, but that wouldn't be a bad thing! |
Update: Made lots of progress. The next version of the crate is largely done. I still need to update the tests to use the new async functions and improve some docs. Then I will take a look at the watch function and make sure there's a good way to cancel the watch. |
Great. Really appreciate your work on this. |
This looks great. Thanks. Are you planning to move up to a new release soon, or are you planning to get more features in first? |
I'm gonna add the members and auth API and then make a new release. |
Is there any way to cancel a watch? Even a simple Client wide close would be really useful.
The text was updated successfully, but these errors were encountered: