Skip to content

Commit 0f40930

Browse files
committed
Initial FinalizeTaskRunService
1 parent ab3198a commit 0f40930

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { marqs } from "~/v3/marqs/index.server";
2+
import { BaseService } from "./baseService.server";
3+
import { type TaskRunStatus } from "@trigger.dev/database";
4+
import { type PrismaClientOrTransaction } from "~/db.server";
5+
6+
type Input = {
7+
tx: PrismaClientOrTransaction;
8+
id: string;
9+
status: TaskRunStatus;
10+
expiredAt?: Date;
11+
completedAt?: Date;
12+
};
13+
14+
//todo
15+
//1. ack
16+
//2. Using the passed in transaction client, update the run status and any optional dates passed in
17+
//3. Remove the run from it's concurrency sets in Redis
18+
//4? Do alerts if the run has failed
19+
20+
export class FinalizeTaskRunService extends BaseService {
21+
public async call({ tx, id, status, expiredAt, completedAt }: Input) {
22+
await marqs?.acknowledgeMessage(id);
23+
24+
const run = await tx.taskRun.update({
25+
where: {
26+
id,
27+
},
28+
data: {
29+
status,
30+
expiredAt,
31+
completedAt,
32+
},
33+
});
34+
35+
return run;
36+
}
37+
}

0 commit comments

Comments
 (0)