-
Notifications
You must be signed in to change notification settings - Fork 101
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
consider removing built-in cancellation mechanism #118
Comments
Thank you for your suggestion, I was assuming a case like Go's context, where the parent's CancellationToken is passed to the child task when the task is generated internally. |
I'm not a Go expert, but I believe their async system works differently, and does require the child task to have an out-of-band explicit cancellation mechanism. Rust futures can be cancelled simply by dropping them. This is why e.g. tonic and reqwest don't have cancellation mechanisms built in. |
@fredr it's possible that cancellation doesn't need to be built in at all. If you have tasks communicating via channels, you can have task shutdown automatically when the remote end of the channel is closed. |
Most of the client APIs appear to take an optional cancellation token. Tokio's
CancellationToken
type is designed to allow alerting a spawned task that cancellation is being requested. Becausegoogle-cloud-rust
isn't spawning tasks, it's not necessary for a cancellation mechanism to be built in to the library. Instead, users of the library can simply drop the futures returned from thegoogle-cloud-rust
APIs, perhaps in response to aCancellationToken
firing, to enable cancellation.The text was updated successfully, but these errors were encountered: