feat: update retry algorithm for qstash
avoids dlq until it has to
This commit is contained in:
@@ -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",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const GetNextEpisodeAiringAtQuery = graphql(`
|
|||||||
status
|
status
|
||||||
nextAiringEpisode {
|
nextAiringEpisode {
|
||||||
episode
|
episode
|
||||||
timeUntilAiring
|
airingAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user