Send an event and any Jobs that subscribe to that event will get triggered.
Name and Schemas
Name
Event triggers have aname
. They will only get triggered when an event with that name are sent.
Schema
Event triggers take a Zod schema. This is used to validate the data that is sent with the event. If the data does not match the schema, the Job will not run. It also means that inside your run function the payload will be typed correctly. We use Zod for our schemas – it’s a fantastic library that allows you to define schemas in a very simple way. You can always start out by usingz.any()
as your schema, and then later on you can add more strict validation. See our Zod guide for more information.
Example
You can subscribe to the same event from multiple different Jobs. This is useful if you want to
send an event to multiple different services or if you want to keep each Job small and simple.
Sending events
There are two ways of sending an event that will Trigger a Job.1. From your own code
You can useclient.sendEvent()
to send an event from your own code. View the SDK reference.
2. From another Job
You can useio.sendEvent()
to send events from inside a Job run, to trigger another. View the SDK reference.
Event filters
They are declarative pattern-matching rules, modeled after AWS EventBridge patterns. Here’s a more detailed explanation of Event filters Given the following custom event payload:status == "ACCEPTED"
, and it would also match if status == "REJECTED"
.