Skip to content

Commit b6e4ba8

Browse files
committed
Allow controlling the delay interval when creating the batch
1 parent 31c8562 commit b6e4ba8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

apps/webapp/app/routes/admin.api.v1.runs-replication.$batchId.backfill.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ const Body = z.object({
88
from: z.coerce.date(),
99
to: z.coerce.date(),
1010
batchSize: z.number().optional(),
11+
delayIntervalMs: z.number().optional(),
1112
});
1213

1314
const Params = z.object({
1415
batchId: z.string(),
1516
});
1617

1718
const DEFAULT_BATCH_SIZE = 500;
19+
const DEFAULT_DELAY_INTERVAL_MS = 1000;
1820

1921
export async function action({ request, params }: ActionFunctionArgs) {
2022
// Next authenticate the request
@@ -43,14 +45,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
4345
try {
4446
const body = await request.json();
4547

46-
const { from, to, batchSize } = Body.parse(body);
48+
const { from, to, batchSize, delayIntervalMs } = Body.parse(body);
4749

4850
await adminWorker.enqueue({
4951
job: "admin.backfillRunsToReplication",
5052
payload: {
5153
from,
5254
to,
5355
batchSize: batchSize ?? DEFAULT_BATCH_SIZE,
56+
delayIntervalMs: delayIntervalMs ?? DEFAULT_DELAY_INTERVAL_MS,
5457
},
5558
id: batchId,
5659
});

apps/webapp/app/v3/services/adminWorker.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function initializeWorker() {
3232
to: z.coerce.date(),
3333
cursor: z.string().optional(),
3434
batchSize: z.coerce.number().int().default(500),
35+
delayIntervalMs: z.coerce.number().int().default(1000),
3536
}),
3637
visibilityTimeoutMs: 60_000 * 15, // 15 minutes
3738
retry: {
@@ -76,9 +77,10 @@ function initializeWorker() {
7677
to: payload.to,
7778
cursor,
7879
batchSize: payload.batchSize,
80+
delayIntervalMs: payload.delayIntervalMs,
7981
},
8082
id,
81-
availableAt: new Date(Date.now() + 1000),
83+
availableAt: new Date(Date.now() + payload.delayIntervalMs),
8284
cancellationKey: id,
8385
});
8486
}

0 commit comments

Comments
 (0)