feat: configure queue retry delays with min/max bounds and update exponential backoff defaults
This commit is contained in:
13
src/index.ts
13
src/index.ts
@@ -123,9 +123,13 @@ export default {
|
||||
},
|
||||
} satisfies ExportedHandler<Env>;
|
||||
|
||||
const retryDelayConfig: Record<QueueName, DurationLike> = {
|
||||
ANILIST_UPDATES: Duration.fromObject({ minutes: 1 }),
|
||||
NEW_EPISODE: Duration.fromObject({ hours: 1 }),
|
||||
const retryDelayConfig: Partial<
|
||||
Record<QueueName, { min: DurationLike; max: DurationLike }>
|
||||
> = {
|
||||
NEW_EPISODE: {
|
||||
min: Duration.fromObject({ hours: 1 }),
|
||||
max: Duration.fromObject({ hours: 12 }),
|
||||
},
|
||||
};
|
||||
|
||||
function onMessageQueue<QN extends QueueName>(
|
||||
@@ -144,7 +148,8 @@ function onMessageQueue<QN extends QueueName>(
|
||||
message.retry({
|
||||
delaySeconds: calculateExponentialBackoff({
|
||||
attempt: message.attempts,
|
||||
baseMin: retryDelayConfig[messageBatch.queue as QN],
|
||||
baseMin: retryDelayConfig[messageBatch.queue as QN]?.min,
|
||||
absCap: retryDelayConfig[messageBatch.queue as QN]?.max,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user