Retry outbound read syncs for up to 24 hours

This commit is contained in:
Evan Hahn 2021-07-23 17:02:36 -05:00 committed by GitHub
parent fc33e9be41
commit 18140c4a9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 366 additions and 19 deletions

View file

@ -93,7 +93,10 @@ export abstract class JobQueue<T> {
* If it rejects, the job will be retried up to `maxAttempts - 1` times, after which it
* will be deleted from the store.
*/
protected abstract run(job: Readonly<ParsedJob<T>>): Promise<void>;
protected abstract run(
job: Readonly<ParsedJob<T>>,
extra?: Readonly<{ attempt: number }>
): Promise<void>;
/**
* Start streaming jobs from the store.
@ -198,7 +201,7 @@ export abstract class JobQueue<T> {
// We want an `await` in the loop, as we don't want a single job running more
// than once at a time. Ideally, the job will succeed on the first attempt.
// eslint-disable-next-line no-await-in-loop
await this.run(parsedJob);
await this.run(parsedJob, { attempt });
result = { success: true };
log.info(
`${this.logPrefix} job ${storedJob.id} succeeded on attempt ${attempt}`