-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webhook-retries): produce and consume retries (3) (#1940)
- Loading branch information
1 parent
663eb75
commit e84794e
Showing
20 changed files
with
908 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
export const TIMEZONE = 'Asia/Singapore' |
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,46 @@ | ||
import config from '../../config/config' | ||
|
||
import { RetryInterval } from './webhook.types' | ||
|
||
/** | ||
* Current version of queue message format. | ||
*/ | ||
export const QUEUE_MESSAGE_VERSION = 0 | ||
|
||
// Conversion to seconds | ||
const hours = (h: number) => h * 60 * 60 | ||
const minutes = (m: number) => m * 60 | ||
|
||
/** | ||
* Encodes retry policy. | ||
* Element 0 is time to wait + jitter before | ||
* retrying the first time, element 1 is time to wait | ||
* to wait + jitter before 2nd time, etc. | ||
* All units are in seconds. | ||
*/ | ||
export const RETRY_INTERVALS: RetryInterval[] = config.isDev | ||
? [ | ||
{ base: 10, jitter: 5 }, | ||
{ base: 20, jitter: 5 }, | ||
{ base: 30, jitter: 5 }, | ||
] | ||
: [ | ||
{ base: minutes(5), jitter: minutes(1) }, | ||
{ base: hours(1), jitter: minutes(30) }, | ||
{ base: hours(2), jitter: minutes(30) }, | ||
{ base: hours(4), jitter: minutes(30) }, | ||
{ base: hours(8), jitter: minutes(30) }, | ||
{ base: hours(24), jitter: minutes(30) }, | ||
] | ||
|
||
/** | ||
* Max possible delay for a message, as specified by AWS. | ||
*/ | ||
export const MAX_DELAY_SECONDS = minutes(15) | ||
|
||
/** | ||
* Tolerance allowed for determining if a message is due to be sent. | ||
* If a message's next attempt is scheduled either in the past or this | ||
* number of seconds in the future, it will be sent. | ||
*/ | ||
export const DUE_TIME_TOLERANCE_SECONDS = minutes(1) |
Oops, something went wrong.