Skip to content

Commit 5611768

Browse files
committed
Improve the job reference
1 parent d0e6442 commit 5611768

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

docs/sdk/job.mdx

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ description: "Job is used to create and configure a Job"
55

66
A [Job](/documentation/concepts/jobs) is used to define the [Trigger](/documentation/concepts/triggers), metadata, and what happens when it runs.
77

8-
By far the most important thing to understand is the constructor.
9-
10-
# Constructor
8+
You can define a job in one of two ways, using the `new Job` constructor or by using the `TriggerClient.defineJob` instance method.
119

1210
<RequestExample>
1311

14-
```ts cronTrigger
15-
client.defineJob({
12+
```ts constructor
13+
new Job(client, {
1614
id: "slack-kpi-summary",
1715
name: "Slack kpi summary",
1816
version: "0.1.1",
@@ -34,7 +32,7 @@ client.defineJob({
3432
});
3533
```
3634

37-
```ts webhook
35+
```ts client.defineJob
3836
client.defineJob({
3937
id: "github-integration-on-issue",
4038
name: "GitHub Integration - On Issue",
@@ -51,38 +49,31 @@ client.defineJob({
5149
});
5250
```
5351

54-
```ts event
52+
```ts queue options
5553
client.defineJob({
56-
id: "openai-joke",
57-
name: "OpenAI Joke",
58-
version: "0.0.1",
59-
trigger: eventTrigger({
60-
name: "openai.joke",
61-
schema: z.object({
62-
jokePrompt: z.string(),
63-
}),
54+
id: "github-integration-on-issue",
55+
name: "GitHub Integration - On Issue",
56+
version: "0.1.0",
57+
trigger: github.triggers.repo({
58+
event: events.onIssue,
59+
owner: "triggerdotdev",
60+
repo: "empty",
6461
}),
65-
integrations: {
66-
openai,
62+
queue: {
63+
name: "my-queue",
64+
maxConcurrent: 10, // only 10 runs can happen at the same time
6765
},
6866
run: async (payload, io, ctx) => {
69-
const joke = await io.openai.backgroundCreateChatCompletion("generate-jokes", {
70-
model: "gpt-3.5-turbo",
71-
messages: [
72-
{
73-
role: "user",
74-
content: payload.jokePrompt,
75-
},
76-
],
77-
});
78-
79-
return joke.choices;
67+
await io.logger.info("This is a simple log info message");
68+
return { payload, ctx };
8069
},
8170
});
8271
```
8372

8473
</RequestExample>
8574

75+
# Constructor
76+
8677
## Parameters
8778

8879
<ParamField body="client" type="object" required>

0 commit comments

Comments
 (0)