feat: update retry algorithm for qstash

avoids dlq until it has to
This commit is contained in:
2024-09-22 16:12:19 -04:00
parent 00d0f641a4
commit 15f680c4d0
4 changed files with 9 additions and 10 deletions

View File

@@ -121,8 +121,8 @@ app.openapi(route, async (c) => {
client.publishJSON({ client.publishJSON({
url: c.req.url, url: c.req.url,
body: { deviceId, watchStatus, titleId, isRetrying: true }, body: { deviceId, watchStatus, titleId, isRetrying: true },
retries: 0, retries: 3,
delay: 60, delay: "1m",
}); });
} }

View File

@@ -7,7 +7,7 @@ const GetNextEpisodeAiringAtQuery = graphql(`
status status
nextAiringEpisode { nextAiringEpisode {
episode episode
timeUntilAiring airingAt
} }
} }
} }

View File

@@ -37,15 +37,14 @@ export async function maybeScheduleNextAiringEpisode(
return; return;
} }
const { timeUntilAiring, episode: nextEpisode } = nextAiring; const { airingAt, episode: nextEpisode } = nextAiring;
const client = new Client({ token: env.QSTASH_TOKEN }); const client = new Client({ token: env.QSTASH_TOKEN });
const { messageId } = await client.publishJSON({ const { messageId } = await client.publishJSON({
url: `${domain}/internal/new-episode`, url: `${domain}/internal/new-episode`,
body: { aniListId, episodeNumber: nextEpisode }, body: { aniListId, episodeNumber: nextEpisode },
retries: 0, retries: 6,
delay: timeUntilAiring, notBefore: airingAt,
contentBasedDeduplication: true,
}); });
await Promise.allSettled([ await Promise.allSettled([
setTitleMessage(env, aniListId, messageId), setTitleMessage(env, aniListId, messageId),

View File

@@ -92,7 +92,7 @@ async function triggerNextEpisodeRoute(titleId: number) {
aniListId: titleId, aniListId: titleId,
episodeNumber: mostRecentEpisodeNumber, episodeNumber: mostRecentEpisodeNumber,
}, },
retries: 0, retries: 6,
}) })
.then(() => true) .then(() => true)
.catch((error) => { .catch((error) => {
@@ -124,8 +124,8 @@ async function triggerNextEpisodeRoute(titleId: number) {
aniListId: titleId, aniListId: titleId,
episodeNumber: title.nextAiringEpisode.episode, episodeNumber: title.nextAiringEpisode.episode,
}, },
retries: 0, retries: 6,
delay: title.nextAiringEpisode.timeUntilAiring, notBefore: title.nextAiringEpisode.airingAt,
}) })
.then(() => true) .then(() => true)
.catch((error) => { .catch((error) => {