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

Provide CancellationToken as optional parameter to all methods, so requests can be cancelled or timed-out. #238

Closed
pianomanjh opened this issue Apr 13, 2018 · 7 comments

Comments

@pianomanjh
Copy link

It is common for APIs involving potentially long http requests, to accept a CancellationToken, such that a call can be cancelled, or timed-out by a user.
It would be fairly simple to add to this API, as it would be just need be passed down to the HttpClient, that accepts one in SendAsync.

@nozzlegear
Copy link
Owner

nozzlegear commented Apr 13, 2018

Good idea! In your mind, how would this look? An overload for each function on a service, making them all accept an optional token?

public List<Something> ListAsync(ListOptions options, CancellationToken token = null)
{
...
}

@pianomanjh
Copy link
Author

yes, any method that results in an HttpRequest could accept an optional token.

@josh-degraw
Copy link

Any traction on this? This could be very helpful in my current use-cases.

IMO It would also be useful to update the ExequteRequestAsync<T> delegate and IRequestExecutionPolicy to either pass in a cancellation token as is, or add an overload that would have a CancellationToken, e.g. the Retry-able execution policies could support cancellation to avoid performance issues at runtime.

@nozzlegear
Copy link
Owner

I’m still open to this! If anyone has the time I’d be happy to review a pull request to get this added in.

@pianomanjh
Copy link
Author

Alright, I can take a stab at this, standby

@pianomanjh
Copy link
Author

PR posted: #476

@nozzlegear
Copy link
Owner

Published in 5.1.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants