feat
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user