feat
CI / Verify (push) Successful in 1m47s
CI / Build immutable images and deploy (push) Successful in 2m51s

This commit is contained in:
2026-10-01 22:53:48 +07:00 Unverified
parent d85687c332
commit bdce288951
10 changed files with 102 additions and 371 deletions
+10
View File
@@ -9,6 +9,7 @@ import {
processOutboxEvent,
} from "@/lib/outbox/processor";
import { closeRedisClient, getRedisClient } from "@/lib/redis/client";
import { removeExpiredUnpaidCheckouts } from "@/lib/commission/cleanup";
let stopping = false;
const stop = () => {
@@ -38,8 +39,17 @@ async function run(): Promise<void> {
const batchSize = positiveInteger("OUTBOX_BATCH_SIZE", 20, 100);
const pollMs = positiveInteger("OUTBOX_POLL_MS", 1_000, 60_000);
const leaseMs = positiveInteger("OUTBOX_LEASE_MS", 30_000, 300_000);
let nextCheckoutCleanup = 0;
while (!stopping) {
if (Date.now() >= nextCheckoutCleanup) {
nextCheckoutCleanup = Date.now() + 60_000;
try {
await removeExpiredUnpaidCheckouts();
} catch (cause) {
console.error("Unable to remove expired unpaid checkouts", cause);
}
}
const events = await claimOutboxEvents(batchSize, leaseMs);
if (events.length === 0) {
await wait(pollMs);