feat: added the ability to cancel scheduled Events based on the event ID#332
Conversation
|
|
Thanks for this @Chigala, will be reviewing tomorrow 👍 |
|
@Chigala I am curious to know, how you have tested sendEvent with some future date in the deliverAt key. because the job immediately runs for me. added my doubt in #230 (comment). please guide me on this. |
|
Hello @RamK777-stack I believe @ericallam has already answered you. You weren't calling the sendEvent function correctly. That's why the job was running immediately. |
ericallam
left a comment
There was a problem hiding this comment.
Looks pretty close! Can you also add a cancelEvent method to the IO class, similar to sendEvent:
trigger.dev/packages/trigger-sdk/src/io.ts
Line 203 in 45c1578
| return json({ error: "Event not found" }, { status: 404 }); | ||
| } | ||
|
|
||
| //update the cancelledAt column in the eventRecord table |
There was a problem hiding this comment.
Can you update this to happen inside a transaction? See this file as an example: https://github.com/triggerdotdev/trigger.dev/blob/improvements/job-run-performance/apps/webapp/app/services/events/deliverEvent.server.ts
Yeah, I realised I had to add that too when I saw your code snippet on Discord. I'll implement it. |
ericallam
left a comment
There was a problem hiding this comment.
A few more requested changes. One other thing is this should be updated to check to make sure the event cancelledAt is not set. If it is set, it should just return:
Description
Added a function to cancel scheduled Events based on their ID.
Changes
api.v1.events.$eventId.cancel.tsto update the cancelledAt column in the EventRecord table to the time the event was cancelled.graphile_worker.remove_jobSQL to remove the job.fixes #230
/claim #230