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

Async Api Methods Should Have a CancellationToken Parameter #221

Closed
mattscully opened this issue Apr 18, 2019 · 2 comments · May be fixed by #393
Closed

Async Api Methods Should Have a CancellationToken Parameter #221

mattscully opened this issue Apr 18, 2019 · 2 comments · May be fixed by #393

Comments

@mattscully
Copy link

mattscully commented Apr 18, 2019

Since all the API SDK methods make HTTP calls (via RestSharp), they should also allow a CancellationToken to be passed in as a parameter. Given that API calls may vary significantly in the time they take to complete (some may query for a quick status and others may download megabytes of documents), it may be quite common to have different timeout expectations for different methods. Accepting a CancellationToken would improve the API by:

  1. Allowing for a timeout to be set by method invocation while still sharing a common Configuration instance.
  2. Allowing the request to be cancelled by a user action.

It is quite common to make the CancellationToken an optional parameter, which I think would make sense here. For example

public async Task<Envelope> GetEnvelopeAsync(
      string accountId,
      string envelopeId,
      EnvelopesApi.GetEnvelopeOptions options = null,
      CancellationToken cancellationToken = default(CancellationToken))
@LarryKlugerDS
Copy link
Contributor

Thank you for the enhancement idea. This idea has not been raised by other developers, so its prioritization will probably be low. If we have many developers asking for the idea, it will be considered more.

@LarryKlugerDS
Copy link
Contributor

Note that the Envelopes::create method does include an asynchronous boolean attribute.

I have filed enhancement request EC-1507

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

Successfully merging a pull request may close this issue.

3 participants