-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[core-http] Throttling retry policy fix in core-http #15832
Merged
Merged
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
0616843
throttling policy fix in core-http
HarshaNalluru 10a3816
remove comment
HarshaNalluru 8bf61fe
typo
HarshaNalluru d876b54
import core-amqp delay from core-util
HarshaNalluru db74514
import core-util
HarshaNalluru 01bd7c4
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js in…
HarshaNalluru a0307af
import { delay } from "@azure/core-util";
HarshaNalluru 78814aa
changelog
HarshaNalluru ff9cb2a
throw abort error check
HarshaNalluru d003ea8
revert core-rest-pipeline
HarshaNalluru 15f9428
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru c774368
import { delay } from "@azure/core-util";
HarshaNalluru daedfbb
fix linter errors
HarshaNalluru 0dd2974
fix build failures
HarshaNalluru 6c4ed84
export { delay } from "@azure/core-util";
HarshaNalluru 0ad0a26
API Report
HarshaNalluru f7e294a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru d80e0d9
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru 97c6f0a
have 2 copies of delay
HarshaNalluru 99f4d41
keep duplicates
HarshaNalluru 8d77016
API Report
HarshaNalluru ed5e621
retain core-util
HarshaNalluru 8977a42
get rid of circular dependencies
HarshaNalluru 3029418
value should be the second argument
HarshaNalluru 75ad58e
update delay to have options bag and additional feedback
HarshaNalluru 6ede956
make async functions and typeguard feedback
HarshaNalluru 37018a1
update app-config and API Report
HarshaNalluru 1a6555b
HttpMockFacade
HarshaNalluru 58b5855
should honor the abort signal passed
HarshaNalluru a3a0a04
remove nock
HarshaNalluru 9b7f233
satisfy linter
HarshaNalluru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { isDefined } from "./typeguards"; | ||
import { AbortError, AbortSignalLike } from "@azure/abort-controller"; | ||
const StandardAbortMessage = "The operation was aborted."; | ||
|
||
/** | ||
* A wrapper for setTimeout that resolves a promise after delayInMs milliseconds. | ||
* @param delayInMs - The number of milliseconds to be delayed. | ||
* @param value - The value to be resolved with after a timeout of t milliseconds. | ||
* @param options - The options for delay - currently abort options | ||
* @param abortSignal - The abortSignal associated with containing operation. | ||
* @param abortErrorMsg - The abort error message associated with containing operation. | ||
* @returns - Resolved promise | ||
*/ | ||
export function delay<T>( | ||
delayInMs: number, | ||
value?: T, | ||
options?: { | ||
abortSignal?: AbortSignalLike; | ||
abortErrorMsg?: string; | ||
} | ||
): Promise<T | void> { | ||
return new Promise((resolve, reject) => { | ||
let timer: ReturnType<typeof setTimeout> | undefined = undefined; | ||
const onAborted: (() => void) | undefined = (): void => { | ||
if (isDefined(timer)) { | ||
clearTimeout(timer); | ||
} | ||
removeListeners(); | ||
return rejectOnAbort(); | ||
}; | ||
|
||
const rejectOnAbort = (): void => { | ||
return reject( | ||
new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage) | ||
); | ||
}; | ||
|
||
const removeListeners = (): void => { | ||
if (options?.abortSignal && onAborted) { | ||
options.abortSignal.removeEventListener("abort", onAborted); | ||
} | ||
}; | ||
|
||
if (options?.abortSignal && options.abortSignal.aborted) { | ||
return rejectOnAbort(); | ||
} | ||
|
||
timer = setTimeout(() => { | ||
removeListeners(); | ||
resolve(value); | ||
}, delayInMs); | ||
|
||
if (options?.abortSignal) { | ||
options.abortSignal.addEventListener("abort", onAborted); | ||
} | ||
}); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
/** | ||
* Helper TypeGuard that checks if the value is not null or undefined. | ||
* @param thing - Anything | ||
* @internal | ||
*/ | ||
export function isDefined<T>(thing: T | undefined | null): thing is T { | ||
return typeof thing !== "undefined" && thing !== null; | ||
} |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we just need to move to corev2 so we can fix #6484