Skip to content

Commit 13abc1e

Browse files
committed
a couple more tweaks
1 parent 4aab1ad commit 13abc1e

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/interfaces.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export type AddJobsFunction = <TSpecs extends readonly AddJobsJobSpec[]>(
134134

135135
export interface Helpers {
136136
/**
137-
* A Logger instance.
137+
* A `Logger` instance.
138138
*/
139139
logger: Logger;
140140

@@ -145,30 +145,30 @@ export interface Helpers {
145145
withPgClient: WithPgClient;
146146

147147
/**
148-
* Adds a job into our queue.
148+
* Adds a job into the Graphile Worker queue.
149149
*/
150150
addJob: AddJobFunction;
151151

152152
/**
153-
* Adds multiple jobs into our queue.
153+
* Adds multiple jobs into the Graphile Worker queue.
154154
*/
155155
addJobs: AddJobsFunction;
156156
}
157157

158158
export interface JobHelpers extends Helpers {
159159
/**
160-
* A Logger instance, scoped to this job.
160+
* A `Logger` instance, scoped to this job.
161161
*/
162162
logger: Logger;
163163

164164
/**
165-
* The currently executing job.
165+
* The whole, currently executing job.
166166
*/
167167
job: Job;
168168

169169
/**
170-
* Get the queue name of the give queue ID (or the currently executing job if
171-
* no queue id is specified).
170+
* Get the queue name of the given queue ID (or of the currently executing job
171+
* if no queue ID is specified).
172172
*/
173173
getQueueName(queueId?: number | null): PromiseOrDirect<string | null>;
174174

@@ -181,7 +181,8 @@ export interface JobHelpers extends Helpers {
181181
): Promise<QueryResult<R>>;
182182

183183
/**
184-
* An AbortSignal that will be triggered when the job should exit.
184+
* A Node `AbortSignal` that will be triggered when the job should exit. It is
185+
* used, for example, for a graceful shutdown request.
185186
*
186187
* @experimental
187188
*/

website/docs/tasks.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ the extension) joined with `/` characters:
8787
How the file is loaded as a task executor will depend on the specific file and
8888
the plugins you have loaded.
8989

90-
## Loading JavaScript task executors
90+
## Loading JavaScript files
9191

9292
With the default preset, Graphile Worker will load `.js`, `.cjs` and `.mjs`
9393
files as task executors using the `import()` function. If the file is a CommonJS
@@ -100,7 +100,7 @@ at the source code of
100100
[`LoadTaskFromJsPlugin.ts`](https://github.com/graphile/worker/blob/main/src/plugins/LoadTaskFromJsPlugin.ts)
101101
for inspiration.
102102

103-
### Loading TypeScript task executors
103+
### Loading TypeScript files
104104

105105
:::tip
106106

@@ -154,9 +154,9 @@ Worker will see this as success. All other exit codes are seen as failure.
154154
### Environment variables
155155

156156
- `GRAPHILE_WORKER_PAYLOAD_FORMAT` &mdash; the encoding that Graphile Worker
157-
used to pass the payload to the binary. Currently this will always be the
158-
string `json`, but you should check this before processing the payload in case
159-
the format changes.
157+
used to pass the payload to the binary. Currently this will be the string
158+
`json`, but you should check this before processing the payload in case the
159+
format changes.
160160
- `GRAPHILE_WORKER_TASK_IDENTIFIER` &mdash; the identifier for the task this
161161
file represents (useful if you want multiple task identifiers to be served by
162162
the same binary file, e.g. via symlinks)
@@ -191,15 +191,19 @@ promises &mdash; i.e. the successful entries will be removed.
191191

192192
### `helpers.abortPromise`
193193

194+
**Experimental**
195+
194196
This is a promise that will reject when [`abortSignal`](#helpersabortsignal)
195197
aborts. This makes it convenient for exiting your task when the abortSignal
196198
fires: `Promise.race([abortPromise, doYourAsyncThing()])`.
197199

198200
### `helpers.abortSignal`
199201

200-
This is a Node `AbortSignal`. Use this to be notified that you should abort your
201-
task early due to a graceful shutdown request. `AbortSignal`s can be passed to a
202-
number of asynchronous Node.js methods like
202+
**Experimental**
203+
204+
This is a Node `AbortSignal` that will be triggered when the job should exit
205+
early. It is used, for example, for a graceful shutdown request. `AbortSignal`s
206+
can be passed to a number of asynchronous Node.js methods like
203207
[`http.request()`](https://nodejs.org/api/http.html#httprequesturl-options-callback).
204208

205209
### `helpers.addJob()`
@@ -212,17 +216,17 @@ See [`addJobs`](/library/add-job.md#add-jobs).
212216

213217
### `helpers.getQueueName()`
214218

215-
Get the name of the queue the job is in, or the queue name of the provided queue
216-
ID. This function may or may not return a promise. We recommend that you always
217-
`await` it.
219+
Get the queue name of the given queue ID (or of the currently executing job if
220+
no queue ID is specified). This function may or may not return a promise. We
221+
recommend that you always `await` it.
218222

219223
### `helpers.job`
220224

221-
The whole job, including `uuid`, `attempts`, etc.
225+
The whole, currently executing job, including `uuid`, `attempts`, etc.
222226

223227
### `helpers.logger`
224228

225-
See [Logger](./library/logger)
229+
A logger instance scoped to this job. See [Logger](./library/logger)
226230

227231
### `helpers.query()`
228232

0 commit comments

Comments
 (0)