@@ -37,16 +37,19 @@ declare global {
37
37
interface Tasks {
38
38
/* extend this through declaration merging */
39
39
}
40
+
40
41
interface MigrateEvent {
41
42
/**
42
43
* The client used to run the migration. Replacing this is not officially
43
44
* supported, but...
44
45
*/
45
46
client : PoolClient ;
47
+
46
48
/**
47
49
* The Postgres version number, e.g. 120000 for PostgreSQL 12.0
48
50
*/
49
51
readonly postgresVersion : number ;
52
+
50
53
/**
51
54
* Somewhere to store temporary data from plugins, only used during
52
55
* premigrate, postmigrate, prebootstrap and postbootstrap
@@ -63,10 +66,11 @@ declare global {
63
66
* @defaultValue `process.env.DATABASE_URL`
64
67
*/
65
68
connectionString ?: string ;
69
+
66
70
/**
67
71
* Maximum number of concurrent connections to Postgres; must be at least
68
72
* `2`. This number can be lower than `concurrentJobs`, however a low
69
- * pool size may cause issues - if all your pool clients are busy then no
73
+ * pool size may cause issues: if all your pool clients are busy then no
70
74
* jobs can be started or released. If in doubt, we recommend setting it
71
75
* to `10` or `concurrentJobs + 2`, whichever is larger. (Note: if your
72
76
* task executors use this pool, then an even larger value may be needed
@@ -75,97 +79,132 @@ declare global {
75
79
* @defaultValue `10`
76
80
*/
77
81
maxPoolSize ?: number ;
82
+
78
83
/**
79
84
*
80
85
* @defaultValue `2000` */
81
86
pollInterval ?: number ;
82
- /** @defaultValue `true` */
87
+
88
+ /**
89
+ * Whether Graphile Worker should use prepared statements. Set `false` if
90
+ * you use software (e.g. some Postgres pools) that don't support them.
91
+ *
92
+ * @defaultValue `true`
93
+ */
83
94
preparedStatements ?: boolean ;
95
+
84
96
/**
85
- * The database schema in which Graphile Worker is (to be) located.
97
+ * The database schema in which Graphile Worker's tables, functions,
98
+ * views, etc are located. Graphile Worker will create or edit things in
99
+ * this schema as necessary.
86
100
*
87
101
* @defaultValue `graphile_worker`
88
102
*/
89
103
schema ?: string ;
104
+
90
105
/**
91
- * Override path to find tasks
106
+ * The path to a directory in which Graphile Worker should look for task
107
+ * executors.
92
108
*
93
109
* @defaultValue `process.cwd() + "/tasks"`
94
110
*/
95
111
taskDirectory ?: string ;
112
+
96
113
/**
97
- * Override path to crontab file.
114
+ * The path to a file in which Graphile Worker should look for crontab
115
+ * schedules. See: [recurring tasks
116
+ * (crontab)](https://worker.graphile.org/docs/cron)).
98
117
*
99
118
* @defaultValue `process.cwd() + "/crontab"`
100
119
*/
101
120
crontabFile ?: string ;
121
+
102
122
/**
103
- * Number of jobs to run concurrently.
123
+ * Number of jobs to run concurrently on a single Graphile Worker
124
+ * instance.
104
125
*
105
126
* @defaultValue `1`
106
127
*/
107
128
concurrentJobs ?: number ;
108
129
109
130
/**
110
131
* A list of file extensions (in priority order) that Graphile Worker
111
- * should attempt to import directly when loading tasks. Defaults to
112
- * `[".js", ".cjs", ".mjs"]`.
132
+ * should attempt to import directly when loading task executors from the
133
+ * file system.
134
+ *
135
+ * @defaultValue `[".js", ".cjs", ".mjs"]`
113
136
*/
114
137
fileExtensions ?: string [ ] ;
115
138
116
139
/**
117
140
* How long in milliseconds after a gracefulShutdown is triggered should
118
- * we wait to trigger the AbortController, which should cancel supported
119
- * asynchronous actions?
141
+ * Graphile Worker wait to trigger the AbortController, which should
142
+ * cancel supported asynchronous actions?
120
143
*
121
- * @defaultValue `5000 `
144
+ * @defaultValue `5_000 `
122
145
*/
123
146
gracefulShutdownAbortTimeout ?: number ;
124
147
125
148
/**
126
- * Set `true` to use the time as recorded by Node.js rather than
149
+ * Set to `true` to use the time as recorded by Node.js rather than
127
150
* PostgreSQL. It's strongly recommended that you ensure the Node.js and
128
151
* PostgreSQL times are synchronized, making this setting moot.
152
+ *
153
+ * @defaultValue `false`
129
154
*/
130
155
useNodeTime ?: boolean ;
131
156
132
157
/**
133
158
* **Experimental**
134
159
*
135
- * How often should we scan for jobs that have been locked too long and
136
- * release them? This is the minimum interval, we'll choose a time between
137
- * this and `maxResetLockedInterval`.
160
+ * How often should Graphile Worker scan for and release jobs that have
161
+ * been locked too long? This is the minimum interval in milliseconds.
162
+ * Graphile Worker will choose a time between this and
163
+ * `maxResetLockedInterval`.
164
+ *
165
+ * @defaultValue `480_000`
138
166
*/
139
167
minResetLockedInterval ?: number ;
168
+
140
169
/**
141
170
* **Experimental**
142
171
*
143
- * The upper bound of how long we'll wait between scans for jobs that have
144
- * been locked too long. See `minResetLockedInterval`.
172
+ * The upper bound of how long (in milliseconds) Graphile Worker will
173
+ * wait between scans for jobs that have been locked too long (see
174
+ * `minResetLockedInterval`).
175
+ *
176
+ * @defaultValue `600_000`
145
177
*/
146
178
maxResetLockedInterval ?: number ;
147
179
148
180
/**
149
181
* **Experimental**
150
182
*
151
- * When getting a queue name in a job, we batch calls for efficiency. By
152
- * default we do this over a 50ms window; increase this for greater efficiency,
153
- * reduce this to reduce the latency for getting an individual queue name.
183
+ * The size, in milliseconds, of the time window over which Graphile
184
+ * Worker will batch requests to retrieve the queue name of a job.
185
+ * Increase the size of this window for greater efficiency, or reduce it
186
+ * to improve latency.
187
+ *
188
+ * @defaultValue `50`
154
189
*/
155
190
getQueueNameBatchDelay ?: number ;
156
191
157
192
/**
158
- * A Logger instance.
193
+ * A Logger instance (see [Logger](https://worker.graphile.org/docs/library/logger)) .
159
194
*/
160
195
logger ?: Logger ;
161
196
162
197
/**
163
- * A Node.js `EventEmitter` that exposes certain events within the runner
164
- * (see
165
- * [`WorkerEvents`](https://worker.graphile.org/docs/worker-events)).
198
+ * Provide your own Node.js `EventEmitter` in order to be able to receive
199
+ * events (see
200
+ * [`WorkerEvents`](https://worker.graphile.org/docs/worker-events)) that
201
+ * occur during Graphile Worker's startup. (Without this, Worker will
202
+ * provision its own `EventEmitter`, but you can't retrieve it until the
203
+ * promise returned by the API you have called has resolved.)
166
204
*/
167
205
events ?: WorkerEvents ;
168
206
}
207
+
169
208
interface Preset {
170
209
worker ?: WorkerOptions ;
171
210
}
@@ -181,6 +220,7 @@ declare global {
181
220
} ;
182
221
} ;
183
222
}
223
+
184
224
interface WorkerHooks {
185
225
/**
186
226
* Called when Graphile Worker starts up.
@@ -224,11 +264,13 @@ declare global {
224
264
* this task identifier (see `details`), you should set it.
225
265
*/
226
266
handler ?: Task ;
267
+
227
268
/**
228
269
* The string that will identify this task (inferred from the file
229
270
* path).
230
271
*/
231
272
readonly taskIdentifier : string ;
273
+
232
274
/**
233
275
* A list of the files (and associated metadata) that match this task
234
276
* identifier.
0 commit comments