Skip to content

Commit 0d99bce

Browse files
authored
update config docs (#520)
2 parents 490c506 + d46128c commit 0d99bce

File tree

5 files changed

+227
-76
lines changed

5 files changed

+227
-76
lines changed

src/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const argv = yargs
5656
.number("poll-interval")
5757
.option("no-prepared-statements", {
5858
description:
59-
"set this flag if you want to disable prepared statements, e.g. for compatibility with pgBouncer",
59+
"set this flag if you want to disable prepared statements, e.g. for compatibility with some external PostgreSQL pools",
6060
})
6161
.boolean("no-prepared-statements")
6262
.option("config", {

src/index.ts

+66-24
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ declare global {
3737
interface Tasks {
3838
/* extend this through declaration merging */
3939
}
40+
4041
interface MigrateEvent {
4142
/**
4243
* The client used to run the migration. Replacing this is not officially
4344
* supported, but...
4445
*/
4546
client: PoolClient;
47+
4648
/**
4749
* The Postgres version number, e.g. 120000 for PostgreSQL 12.0
4850
*/
4951
readonly postgresVersion: number;
52+
5053
/**
5154
* Somewhere to store temporary data from plugins, only used during
5255
* premigrate, postmigrate, prebootstrap and postbootstrap
@@ -63,10 +66,11 @@ declare global {
6366
* @defaultValue `process.env.DATABASE_URL`
6467
*/
6568
connectionString?: string;
69+
6670
/**
6771
* Maximum number of concurrent connections to Postgres; must be at least
6872
* `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
7074
* jobs can be started or released. If in doubt, we recommend setting it
7175
* to `10` or `concurrentJobs + 2`, whichever is larger. (Note: if your
7276
* task executors use this pool, then an even larger value may be needed
@@ -75,97 +79,132 @@ declare global {
7579
* @defaultValue `10`
7680
*/
7781
maxPoolSize?: number;
82+
7883
/**
7984
*
8085
* @defaultValue `2000` */
8186
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+
*/
8394
preparedStatements?: boolean;
95+
8496
/**
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.
86100
*
87101
* @defaultValue `graphile_worker`
88102
*/
89103
schema?: string;
104+
90105
/**
91-
* Override path to find tasks
106+
* The path to a directory in which Graphile Worker should look for task
107+
* executors.
92108
*
93109
* @defaultValue `process.cwd() + "/tasks"`
94110
*/
95111
taskDirectory?: string;
112+
96113
/**
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)).
98117
*
99118
* @defaultValue `process.cwd() + "/crontab"`
100119
*/
101120
crontabFile?: string;
121+
102122
/**
103-
* Number of jobs to run concurrently.
123+
* Number of jobs to run concurrently on a single Graphile Worker
124+
* instance.
104125
*
105126
* @defaultValue `1`
106127
*/
107128
concurrentJobs?: number;
108129

109130
/**
110131
* 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"]`
113136
*/
114137
fileExtensions?: string[];
115138

116139
/**
117140
* 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?
120143
*
121-
* @defaultValue `5000`
144+
* @defaultValue `5_000`
122145
*/
123146
gracefulShutdownAbortTimeout?: number;
124147

125148
/**
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
127150
* PostgreSQL. It's strongly recommended that you ensure the Node.js and
128151
* PostgreSQL times are synchronized, making this setting moot.
152+
*
153+
* @defaultValue `false`
129154
*/
130155
useNodeTime?: boolean;
131156

132157
/**
133158
* **Experimental**
134159
*
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`
138166
*/
139167
minResetLockedInterval?: number;
168+
140169
/**
141170
* **Experimental**
142171
*
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`
145177
*/
146178
maxResetLockedInterval?: number;
147179

148180
/**
149181
* **Experimental**
150182
*
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`
154189
*/
155190
getQueueNameBatchDelay?: number;
156191

157192
/**
158-
* A Logger instance.
193+
* A Logger instance (see [Logger](https://worker.graphile.org/docs/library/logger)).
159194
*/
160195
logger?: Logger;
161196

162197
/**
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.)
166204
*/
167205
events?: WorkerEvents;
168206
}
207+
169208
interface Preset {
170209
worker?: WorkerOptions;
171210
}
@@ -181,6 +220,7 @@ declare global {
181220
};
182221
};
183222
}
223+
184224
interface WorkerHooks {
185225
/**
186226
* Called when Graphile Worker starts up.
@@ -224,11 +264,13 @@ declare global {
224264
* this task identifier (see `details`), you should set it.
225265
*/
226266
handler?: Task;
267+
227268
/**
228269
* The string that will identify this task (inferred from the file
229270
* path).
230271
*/
231272
readonly taskIdentifier: string;
273+
232274
/**
233275
* A list of the files (and associated metadata) that match this task
234276
* identifier.

src/interfaces.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,8 @@ export interface SharedOptions {
669669

670670
/**
671671
* Set true if you want to prevent the use of prepared statements; for
672-
* example if you wish to use Graphile Worker with pgBouncer or similar.
672+
* example if you wish to use Graphile Worker with a connection pool that
673+
* does not support prepared statements.
673674
*/
674675
noPreparedStatements?: boolean;
675676

website/docs/cli/run.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ different role, one solution is to explicitly change the owner of the
3232

3333
## CLI options
3434

35-
The following CLI options are available:
35+
The following CLI options are available (`graphile-worker --help`):
3636

3737
```
3838
Options:
@@ -41,23 +41,26 @@ Options:
4141
-c, --connection Database connection string, defaults to the
4242
'DATABASE_URL' envvar [string]
4343
-s, --schema The database schema in which Graphile Worker is
44-
(to be) located
45-
[string] [default: "graphile_worker"]
44+
(to be) located [string]
4645
--schema-only Just install (or update) the database schema,
4746
then exit [boolean] [default: false]
4847
--once Run until there are no runnable jobs left, then
4948
exit [boolean] [default: false]
5049
--crontab override path to crontab file [string]
51-
-j, --jobs number of jobs to run concurrently
52-
[number] [default: 1]
53-
-m, --max-pool-size maximum size of the PostgreSQL pool
54-
[number] [default: 10]
50+
-j, --jobs number of jobs to run concurrently [number]
51+
-m, --max-pool-size maximum size of the PostgreSQL pool [number]
5552
--poll-interval how long to wait between polling for jobs in
5653
milliseconds (for jobs scheduled in the
57-
future/retries) [number] [default: 2000]
54+
future/retries) [number]
5855
--no-prepared-statements set this flag if you want to disable prepared
59-
statements, e.g. for compatibility with
60-
pgBouncer [boolean] [default: false]
56+
statements, e.g. for compatibility with some
57+
external PostgreSQL pools [boolean]
58+
-C, --config The path to the config file [string]
59+
--cleanup Clean the database, then exit. Accepts a
60+
comma-separated list of cleanup tasks:
61+
GC_TASK_IDENTIFIERS, GC_JOB_QUEUES,
62+
DELETE_PERMAFAILED_JOBS [string]
63+
6164
```
6265

6366
## Connection string

0 commit comments

Comments
 (0)