Jobs, Runs & Tasks
Jobs
When this happens, do this.
A Job defines what event triggers it and what should happen when it is run.
For example, you can create a Job that will send an email to a user when they sign up for your app.
Anatomy of a Job
A Job is made up of a few things:
- Metadata
- A Trigger (what event should cause this job to run)
- The Run function (what should happen when this job runs)
//Job definition – uses the client
client.defineJob({
// 1. Metadata
id: "event-1",
name: "Run when the foo.bar event happens",
version: "0.0.1",
// 2. Trigger
trigger: eventTrigger({
name: "foo.bar",
}),
// 3. Run function
run: async (payload, io, ctx) => {
// do something
},
});
Jobs, Triggers, Runs and Tasks
A more complicated Job
When a GitHub issue is modified: If the issue has been labelled “critical” send a Slack message and sync the issue to Linear.
This can be visualized like this:
Events trigger Jobs. Jobs generate a Run for every event. A Run is a single execution of a Job. A Run can have multiple Tasks which are the individual steps of a Run.
References
Was this page helpful?