Add optional CancellationToken support across the client API - #3079
Open
hughesjs wants to merge 8 commits into
Open
Add optional CancellationToken support across the client API#3079hughesjs wants to merge 8 commits into
hughesjs wants to merge 8 commits into
Conversation
Add CancellationToken cancellationToken = default as trailing parameter to all 7 GetAndFlattenAllPages* overloads in ConnectionExtensions.cs, forwarding the token to the underlying connection.Get<List<T>> calls. Update 45 reactive test files to use the new 4-arg Get<List<T>> form (uri, dict, Arg.Any<string>(), Arg.Any<CancellationToken>()), and add a new ConnectionExtensionsTests.cs to verify token propagation.
…-assertion mismatches remain)
…convention tests green
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
CancellationToken cancellationToken = defaultto the public client API acrossOctokitandOctokit.Reactive, threaded from the client methods down throughApiConnection/Connectionto the HTTP layer (which already accepted a token). Follows the existing in-place precedent set by #2988 (OAuth client) rather than adding parallel overloads.Implements the request in #1840. Also relevant to #744 (per-request timeouts) and #2956 (making timeouts/cancellation actually useful), since a caller-supplied
CancellationTokenenables per-request cancellation/timeout.Scope
IApiConnection/ApiConnectionand the ReactiveGetAndFlattenAllPageshelpers now accept and forward the token.Task/Task<T>method (andIObservable<T>method on the reactive clients) gained the trailing optional token, threaded into the underlying call.params-array methods are intentionally left unchanged (C# disallows a parameter afterparams).concellationTokentypo inIOAuthClient.Compatibility
Source-compatible for callers (trailing optional parameter with a default). Existing behaviour is unchanged when no token is supplied.
Verification
Octokit.Tests: 4552 passed, 0 failed, 2 skipped.Octokit.Tests.Conventions: 2827 passed, 0 failed.