-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PECO-729] Improve retry behavior (#230)
* [PECO-729] Respect `Retry-After` header with falling back to backoff algorithm Signed-off-by: Levko Kravets <[email protected]> * [PECO-729] Extend list of HTTP status codes that could be retried Signed-off-by: Levko Kravets <[email protected]> * Pass `Request` object in addition to `Response` to `HttpRetryPolicy` Signed-off-by: Levko Kravets <[email protected]> * [PECO-729] Retry only idempotent requests (HTTP GET + restricted set of Thrift operations) Signed-off-by: Levko Kravets <[email protected]> * Update HttpRetryPolicy logic; add/update tests Signed-off-by: Levko Kravets <[email protected]> * Reduce max retry attempts to 5 Signed-off-by: Levko Kravets <[email protected]> * Use `Retry-After` as a base for backoff, not instead of it Signed-off-by: Levko Kravets <[email protected]> --------- Signed-off-by: Levko Kravets <[email protected]>
- Loading branch information
1 parent
08bbdfc
commit 6673660
Showing
13 changed files
with
566 additions
and
108 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import IRetryPolicy, { ShouldRetryResult, RetryableOperation } from '../contracts/IRetryPolicy'; | ||
|
||
export default class NullRetryPolicy<R> implements IRetryPolicy<R> { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public async shouldRetry(details: R): Promise<ShouldRetryResult> { | ||
return { shouldRetry: false }; | ||
} | ||
|
||
public async invokeWithRetry(operation: RetryableOperation<R>): Promise<R> { | ||
// Just invoke the operation, don't attempt to retry it | ||
return operation(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import http from 'http'; | ||
import { HeadersInit, Response } from 'node-fetch'; | ||
import { HeadersInit, Request, Response } from 'node-fetch'; | ||
import IRetryPolicy from './IRetryPolicy'; | ||
|
||
export interface HttpTransactionDetails { | ||
request: Request; | ||
response: Response; | ||
} | ||
|
||
export default interface IConnectionProvider { | ||
getThriftConnection(): Promise<any>; | ||
|
||
getAgent(): Promise<http.Agent>; | ||
|
||
setHeaders(headers: HeadersInit): void; | ||
|
||
getRetryPolicy(): Promise<IRetryPolicy<Response>>; | ||
getRetryPolicy(): Promise<IRetryPolicy<HttpTransactionDetails>>; | ||
} |
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
Oops, something went wrong.