Skip to content

Commit 2c0422c

Browse files
committed
add async toggle to process in background
1 parent 924d788 commit 2c0422c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

apps/coordinator/src/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,11 @@ class TaskCoordinator {
14251425
keepRunAlive = json.keepRunAlive;
14261426
}
14271427

1428+
let async = false;
1429+
if ("async" in json && typeof json.async === "boolean") {
1430+
async = json.async;
1431+
}
1432+
14281433
const { runId, now, ms } = json;
14291434

14301435
if (!runId) {
@@ -1440,6 +1445,10 @@ class TaskCoordinator {
14401445

14411446
console.log("Manual duration checkpoint", data);
14421447

1448+
if (async) {
1449+
return reply.text("Creating checkpoint in the background", 202);
1450+
}
1451+
14431452
const checkpoint = await this.#checkpointer.checkpointAndPush({
14441453
runId: data.runId,
14451454
projectRef: data.projectRef,
@@ -1473,6 +1482,7 @@ class TaskCoordinator {
14731482
message: `keeping run ${runId} alive after checkpoint`,
14741483
checkpoint,
14751484
requestJson: json,
1485+
platformAck: ack,
14761486
});
14771487
}
14781488

@@ -1484,6 +1494,7 @@ class TaskCoordinator {
14841494
message: `checkpoint created for run ${runId}`,
14851495
checkpoint,
14861496
requestJson: json,
1497+
platformAck: ack,
14871498
});
14881499
} catch (error) {
14891500
return reply.json({
@@ -1515,6 +1526,11 @@ class TaskCoordinator {
15151526
keepRunAlive = json.keepRunAlive;
15161527
}
15171528

1529+
let async = false;
1530+
if ("async" in json && typeof json.async === "boolean") {
1531+
async = json.async;
1532+
}
1533+
15181534
const { runId } = json;
15191535

15201536
if (!runId) {
@@ -1530,6 +1546,10 @@ class TaskCoordinator {
15301546

15311547
console.log("Manual checkpoint", data);
15321548

1549+
if (async) {
1550+
return reply.text("Creating checkpoint in the background", 202);
1551+
}
1552+
15331553
const checkpoint = await this.#checkpointer.checkpointAndPush({
15341554
runId: data.runId,
15351555
projectRef: data.projectRef,
@@ -1562,6 +1582,7 @@ class TaskCoordinator {
15621582
message: `keeping run ${runId} alive after checkpoint`,
15631583
checkpoint,
15641584
requestJson: json,
1585+
platformAck: ack,
15651586
});
15661587
}
15671588

@@ -1573,6 +1594,7 @@ class TaskCoordinator {
15731594
message: `checkpoint created for run ${runId}`,
15741595
checkpoint,
15751596
requestJson: json,
1597+
platformAck: ack,
15761598
});
15771599
} catch (error) {
15781600
return reply.json({

0 commit comments

Comments
 (0)