@zukhruf/pool 0.8.162 → 0.8.163

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -264,12 +264,12 @@ The store keeps the wall time of each job, so `Pool` and `PoolWorkers` take a `W
264
264
 
265
265
  ## The rules
266
266
 
267
- - **One owner.** On each computer, one host owns the workers of a pool. `PoolWorkers` campaigns in a `SqliteElection` of [`@zukhruf/election`](../election/README.md), with the claim files in the folder of the store. The other hosts with a `PoolWorkers` are standbys ([ADR 0011](./docs/adr/0011-every-pool-is-a-pool-for-the-computer-and-one-owner-pulls-its-jobs-from-a-store-that-every-host-writes-to.md)).
267
+ - **One owner.** On each computer, one host owns the workers of a pool. `PoolWorkers` leads in a `SqliteElection` of [`@zukhruf/election`](../election/README.md), with the claim files in the folder of the store, through a `LeaderSelector` with `autoRequeue`: the host owns for each term that it wins, and campaigns again after each term, as client-go's `LeaderElector` does. The other hosts with a `PoolWorkers` are standbys ([ADR 0011](./docs/adr/0011-every-pool-is-a-pool-for-the-computer-and-one-owner-pulls-its-jobs-from-a-store-that-every-host-writes-to.md)).
268
268
  - **The two roles.** `Pool` sends. `PoolWorkers` offers workers and has no `run`. They meet only through the worker kind and the store, as BullMQ's `Queue` and `Worker` meet through the queue name ([ADR 0013](./docs/adr/0013-pool-sends-jobs-and-pool-workers-offers-the-workers-of-its-host.md)).
269
269
  - **A job is data.** The input and the output are JSON. A file goes by reference: a path on one computer. The code of a job is the worker's `run` ([ADR 0012](./docs/adr/0012-a-job-is-data-and-the-worker-kind-runs-it.md)).
270
270
  - **The store** is a required address. A path of a SQLite file is the store of one computer, through [`@zukhruf/sqlite-queue`](../sqlite/queue/README.md). A `postgres://` address joins computers, through pg-boss. `computerStore(env)` gives `zukhruf-pool/store.sqlite` in the user's state folder: `$HOME/Library/Application Support` on macOS, `$XDG_STATE_HOME` (or `$HOME/.local/state`) on Linux, `%LOCALAPPDATA%` on Windows. It reads `process.platform`, and takes `env` as its input, as Go's `os.UserConfigDir` reads `runtime.GOOS`. Every `Pool` and `PoolWorkers` opens the store and creates the queue of its revision ([ADR 0015](./docs/adr/0015-the-store-is-a-required-input-and-computer-store-gives-the-store-of-the-computer.md)).
271
271
  - **The clock.** The store keeps the wall time of each job, so `Pool` and `PoolWorkers` take a `WallClock` of [`@zukhruf/async`](../async/README.md): `globalThis` in production. The pool gives `@zukhruf/sqlite-queue` pg-boss's clock, made from it.
272
- - **A failure of the store** that no caller waits for, in a pass of the store, a fetch, a touch or a settle of the owner, is a process warning, and the owner keeps owning: the next pass, backstop or touch tries again, and a job whose settle failed lapses by its heartbeat and runs again by the kind's rules, as pg-boss emits the failure of a pass and keeps polling. Ownership ends only by the election or the disposal. A store that fails to start ends the host, and the disposal of `PoolWorkers` rejects with that failure.
272
+ - **A failure of the store** that no caller waits for, in a pass of the store, a fetch, a touch or a settle of the owner, is a process warning, and the owner keeps owning: the next pass, backstop or touch tries again, and a job whose settle failed lapses by its heartbeat and runs again by the kind's rules, as pg-boss emits the failure of a pass and keeps polling. Ownership ends only by the election or the disposal. A campaign that fails is a process warning too, and the host campaigns again after client-go's `RetryPeriod` of 2 s with its `JitterFactor` of 1.2: 2 s to 4.4 s on the pool's clock, as client-go, Curator's `autoRequeue` and Spring's `LockRegistryLeaderInitiator` try again. A store that fails to start ends the host, and the disposal of `PoolWorkers` rejects with that failure. A store whose folder is on a network file system is such a store: its start rejects with `NetworkDirectoryError` before the election campaigns, because the file locks of the store and of the election do not hold there.
273
273
  - **The disposal** of `PoolWorkers` can run again, or at the same time: each call waits for the one end of the host, which closes the store last.
274
274
  - **The cap.** The owner's sizing caps the jobs of its computer. The store keeps no count of running jobs. A new owner starts its sizing fresh ([ADR 0016](./docs/adr/0016-the-owners-sizing-caps-the-jobs-of-its-computer.md)).
275
275
  - **The owner asks, then takes.** It calls `fetch(name, { batchSize: free })` on the queue of its revision for its free workers, settles each job with `complete` or `fail` by its attempt, and calls `touch` for each running job every 5 s on a heartbeat of 10 s. It fetches when a worker becomes free, at a "new job" wake, and at the backstop ([ADR 0017](./docs/adr/0017-the-owner-asks-then-takes-as-many-jobs-as-it-has-free-workers.md)).
@@ -289,36 +289,38 @@ The store keeps the wall time of each job, so `Pool` and `PoolWorkers` take a `W
289
289
 
290
290
  ## Errors
291
291
 
292
- | Error | When |
293
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
294
- | `JobFailedError` | `run` or `result` rejects with it when the job failed its last run. `failure` has the name and the message that the owner stored, for example the worker's error, or "handler execution exceeded 60s", or the store's "job heartbeat timeout" ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
295
- | `JobCancelledError` | `run` or `result` rejects with it when the job was cancelled, by `cancel()` of a handle or by the abort of a `run` of another caller. |
296
- | `JobNotFoundError` | `result` rejects with it when the store has no job with the id: it was deleted after the retention, it belongs to another revision, or it never existed. |
297
- | `DeprecatedRevisionError` | `start`, `run` or `result` rejects with it, and `ready()` of a host that never owned, when the store holds a newer revision of the kind: update the host. `kind`, `revision` and `newest` name the kind, the host's revision and the newest ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
298
- | `DisposedError` | `run`, `result`, `start` or `cancel()` rejects with it when the host disposed its `Pool`, also while it waited. |
299
- | The reason of `signal` | `run` or `result` rejects with it when the caller's signal aborted. |
300
- | `RangeError` | `new WorkerKind` gets a name whose channel `<name>.new-job` has 64 bytes or more ([src/worker-kind.test.ts](./src/worker-kind.test.ts)). |
301
- | `RangeError` | `new IdleTimeout({ after })` gets an `after` that is not above 0 and at most 2,147,483,647 ([src/pool.test.ts](./src/pool.test.ts)). |
302
- | `TypeError` | `new Pool` or `new PoolWorkers` gets a `postgres://` store. Only the store of one computer, the path of a SQLite file, is built ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
303
- | `Error` | `computerStore(env)` finds no `$HOME` on macOS, no `$HOME` and no `$XDG_STATE_HOME` on Linux, or no `%LOCALAPPDATA%` on Windows ([src/computer-store.test.ts](./src/computer-store.test.ts)). |
304
- | The failure of the store | The disposal of `PoolWorkers`, and `start` of a `Pool`, reject with the failure of the store's start, for example an `expireInSeconds` that the store refuses ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). A later failure of the store is a process warning. |
305
- | The error of the warm-up | `workers.ready()` rejects with it when a worker that the startup of the owner starts fails its `ready()` ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
306
- | `AbortError` | `workers.ready()` rejects with it when you dispose `PoolWorkers` before its host owns ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
307
-
308
- A failure that no caller waits for is a process warning, in the shape of [root ADR 0010](../../docs/adr/0010-a-package-warning-names-its-type-code-and-subject-and-keeps-the-failure-as-its-cause.md). A `'warning'` listener reads its type as `name`, its `code`, and its subject in `detail`, one `<term>: <value>` line each. Its `cause` is the failure, and its message ends with the failure's message. `--disable-warning=<code or type>` stops the print. `PoolWarning` is a class that the package exports, and its `code` names the condition, so a listener can test `warning instanceof` the class ([root ADR 0011](../../docs/adr/0011-a-package-warning-is-an-instance-of-its-own-class-which-the-package-exports.md)). With two installed copies of the package, `instanceof` fails across the copies, so compare `code`.
309
-
310
- | Warning | Code | Detail | When |
311
- | ------------- | -------------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
312
- | `PoolWarning` | `ZUKHRUF_POOL_QUEUE_ERROR` | `queue: <name>` | The queue of the store emits `'error'`. The pool goes on. |
313
- | `PoolWarning` | `ZUKHRUF_POOL_NOTIFICATIONS_ERROR` | `queue: <name>` | The notifications of the store emit `'error'`. The backstop finds the lost wakes. |
314
- | `PoolWarning` | `ZUKHRUF_POOL_NOTIFY_FAILED` | `channel: <channel>` | A notify fails after its write committed. The backstop finds the lost wake. |
315
- | `PoolWarning` | `ZUKHRUF_POOL_OWNER_CONNECTION_ERROR` | `queue: <name>` | The connection of an owner to a `Pool` breaks. The pool drops it. |
316
- | `PoolWarning` | `ZUKHRUF_POOL_FETCH_FAILED` | `queue: <name>` | A fetch of the owner fails. The owner waits for the backstop. |
317
- | `PoolWarning` | `ZUKHRUF_POOL_SETTLE_FAILED` | `queue: <name>` and `job: <id>` | The settle of a job fails. The job lapses by its heartbeat. |
318
- | `PoolWarning` | `ZUKHRUF_POOL_TOUCH_FAILED` | `queue: <name>` and `job: <id>` | A touch of a job fails. The job keeps its worker, and the next touch tries again. |
319
- | `PoolWarning` | `ZUKHRUF_POOL_CALLER_CONNECTION_ERROR` | `queue: <name>` | The connection of the owner to the caller of a job breaks for a reason other than a caller that is gone. The owner treats the caller as gone. |
320
- | `PoolWarning` | `ZUKHRUF_POOL_REVISIONS_READ_FAILED` | `queue: <name>` | A read of the revisions in the store fails. The host reads again at its next wake of a newer revision or its next term ([ADR 0022](./docs/adr/0022-the-newest-revision-takes-over-and-the-store-deprecates-every-older-revision.md)). |
321
- | `PoolWarning` | `ZUKHRUF_POOL_CALLER_PRESENCE_REMOVE_FAILED` | `queue: <name>` | The removal of a gone caller's presence file fails. The file stays for the next owner that finds that caller gone (#5424). |
292
+ | Error | When |
293
+ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
294
+ | `JobFailedError` | `run` or `result` rejects with it when the job failed its last run. `failure` has the name and the message that the owner stored, for example the worker's error, or "handler execution exceeded 60s", or the store's "job heartbeat timeout" ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
295
+ | `JobCancelledError` | `run` or `result` rejects with it when the job was cancelled, by `cancel()` of a handle or by the abort of a `run` of another caller. |
296
+ | `JobNotFoundError` | `result` rejects with it when the store has no job with the id: it was deleted after the retention, it belongs to another revision, or it never existed. |
297
+ | `DeprecatedRevisionError` | `start`, `run` or `result` rejects with it, and `ready()` of a host that never owned, when the store holds a newer revision of the kind: update the host. `kind`, `revision` and `newest` name the kind, the host's revision and the newest ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
298
+ | `DisposedError` | `run`, `result`, `start` or `cancel()` rejects with it when the host disposed its `Pool`, also while it waited. |
299
+ | The reason of `signal` | `run` or `result` rejects with it when the caller's signal aborted. |
300
+ | `RangeError` | `new WorkerKind` gets a name whose channel `<name>.new-job` has 64 bytes or more ([src/worker-kind.test.ts](./src/worker-kind.test.ts)). |
301
+ | `RangeError` | `new IdleTimeout({ after })` gets an `after` that is not above 0 and at most 2,147,483,647 ([src/pool.test.ts](./src/pool.test.ts)). |
302
+ | `TypeError` | `new Pool` or `new PoolWorkers` gets a `postgres://` store. Only the store of one computer, the path of a SQLite file, is built ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
303
+ | `Error` | `computerStore(env)` finds no `$HOME` on macOS, no `$HOME` and no `$XDG_STATE_HOME` on Linux, or no `%LOCALAPPDATA%` on Windows ([src/computer-store.test.ts](./src/computer-store.test.ts)). |
304
+ | `NetworkDirectoryError` | The disposal and `ready()` of `PoolWorkers`, and `start` of a `Pool`, reject with it when the folder of the store is on a network file system, where file locks are not shared reliably between machines. `fileSystem` names the file system, for example `NFS`. The class is the one of [`@zukhruf/fs`](../fs/README.md) ([src/pool-workers.test.ts](./src/pool-workers.test.ts), Linux only). |
305
+ | The failure of the store | The disposal of `PoolWorkers`, and `start` of a `Pool`, reject with the failure of the store's start, for example an `expireInSeconds` that the store refuses ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). A later failure of the store is a process warning. |
306
+ | The error of the warm-up | `workers.ready()` rejects with it when a worker that the startup of the owner starts fails its `ready()` ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
307
+ | `AbortError` | `workers.ready()` rejects with it when you dispose `PoolWorkers` before its host owns ([src/pool-workers.test.ts](./src/pool-workers.test.ts)). |
308
+
309
+ A failure that no caller waits for is a process warning, in the shape of [root ADR 0010](../../docs/adr/0010-a-package-warning-names-its-type-code-and-subject-and-keeps-the-failure-as-its-cause.md). A `'warning'` listener reads its type as `name`, its `code`, and its subject in `detail`, one `<term>: <value>` line each. Its `cause` is the failure, and its message ends with the failure's message. `--disable-warning=<code or type>` stops the print. `PoolWarning` is a class that the package exports, and so is `LeaderSelectorWarning` of [`@zukhruf/election`](../election/README.md); the `code` of each names the condition, so a listener can test `warning instanceof` the class ([root ADR 0011](../../docs/adr/0011-a-package-warning-is-an-instance-of-its-own-class-which-the-package-exports.md)). With two installed copies of the package, `instanceof` fails across the copies, so compare `code`.
310
+
311
+ | Warning | Code | Detail | When |
312
+ | ----------------------- | -------------------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
313
+ | `PoolWarning` | `ZUKHRUF_POOL_QUEUE_ERROR` | `queue: <name>` | The queue of the store emits `'error'`. The pool goes on. |
314
+ | `PoolWarning` | `ZUKHRUF_POOL_NOTIFICATIONS_ERROR` | `queue: <name>` | The notifications of the store emit `'error'`. The backstop finds the lost wakes. |
315
+ | `PoolWarning` | `ZUKHRUF_POOL_NOTIFY_FAILED` | `channel: <channel>` | A notify fails after its write committed. The backstop finds the lost wake. |
316
+ | `PoolWarning` | `ZUKHRUF_POOL_OWNER_CONNECTION_ERROR` | `queue: <name>` | The connection of an owner to a `Pool` breaks. The pool drops it. |
317
+ | `PoolWarning` | `ZUKHRUF_POOL_FETCH_FAILED` | `queue: <name>` | A fetch of the owner fails. The owner waits for the backstop. |
318
+ | `PoolWarning` | `ZUKHRUF_POOL_SETTLE_FAILED` | `queue: <name>` and `job: <id>` | The settle of a job fails. The job lapses by its heartbeat. |
319
+ | `PoolWarning` | `ZUKHRUF_POOL_TOUCH_FAILED` | `queue: <name>` and `job: <id>` | A touch of a job fails. The job keeps its worker, and the next touch tries again. |
320
+ | `PoolWarning` | `ZUKHRUF_POOL_CALLER_CONNECTION_ERROR` | `queue: <name>` | The connection of the owner to the caller of a job breaks for a reason other than a caller that is gone. The owner treats the caller as gone. |
321
+ | `PoolWarning` | `ZUKHRUF_POOL_REVISIONS_READ_FAILED` | `queue: <name>` | A read of the revisions in the store fails. The host reads again at its next wake of a newer revision or its next term ([ADR 0022](./docs/adr/0022-the-newest-revision-takes-over-and-the-store-deprecates-every-older-revision.md)). |
322
+ | `PoolWarning` | `ZUKHRUF_POOL_CALLER_PRESENCE_REMOVE_FAILED` | `queue: <name>` | The removal of a gone caller's presence file fails. The file stays for the next owner that finds that caller gone (#5424). |
323
+ | `LeaderSelectorWarning` | `ZUKHRUF_ELECTION_LEADER_SELECTOR_CAMPAIGN_FAILED` | `election: <claim file>` | A campaign of the host fails. The host waits 2 s to 4.4 s on its clock and campaigns again, and its `ready()` stays pending ([ADR 0024](./docs/adr/0024-a-hung-owner-is-ended-by-the-election-and-its-late-acts-are-fenced.md)). |
322
324
 
323
325
  ## API
324
326
 
@@ -377,7 +379,7 @@ class PoolWorkers<Input, Output> implements AsyncDisposable {
377
379
  }); // TypeError: a postgres:// store
378
380
  readonly stats: PoolStats; // this host's slots; each count 0 while it does not own
379
381
  ready(): Promise<void>; // the host owns and its startup's workers are ready; rejects with DeprecatedRevisionError on a host that never owned
380
- [Symbol.asyncDispose](): Promise<void>; // a hand-over; rejects with the failure of the store's start
382
+ [Symbol.asyncDispose](): Promise<void>; // a hand-over; rejects with the failure of the store's start, NetworkDirectoryError too
381
383
  }
382
384
 
383
385
  function computerStore(env: Record<string, string | undefined>): string;
@@ -401,6 +403,7 @@ class DeprecatedRevisionError extends Error {
401
403
  readonly newest: number; // the newest in the store
402
404
  }
403
405
  class DisposedError extends Error {}
406
+ // Re-exported: NetworkDirectoryError of @zukhruf/fs, LeaderSelectorWarning of @zukhruf/election.
404
407
 
405
408
  class PoolWarning extends Error {
406
409
  readonly code: PoolWarningSubject['code'];
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export { OrderedReady } from './ordered-ready.ts';
10
10
  export { Parallel } from './parallel.ts';
11
11
  export { DeprecatedRevisionError, DisposedError, type Failure, JobCancelledError, JobFailedError, JobNotFoundError, } from './errors.ts';
12
12
  export { type JobCounts, type JobHandle, Pool } from './pool.ts';
13
+ export { LeaderSelectorWarning } from '@zukhruf/election';
14
+ export { NetworkDirectoryError } from '@zukhruf/fs';
13
15
  export { PoolWorkers } from './pool-workers.ts';
14
16
  export { PoolWarning, type PoolWarningSubject } from './pool-warning.ts';
15
17
  export type { PoolStats } from './pool-stats.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,KAAK,OAAO,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,QAAQ,EA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AW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -9,6 +9,8 @@ export { OrderedReady } from './ordered-ready.js';
9
9
  export { Parallel } from './parallel.js';
10
10
  export { DeprecatedRevisionError, DisposedError, JobCancelledError, JobFailedError, JobNotFoundError, } from './errors.js';
11
11
  export { Pool } from './pool.js';
12
+ export { LeaderSelectorWarning } from '@zukhruf/election';
13
+ export { NetworkDirectoryError } from '@zukhruf/fs';
12
14
  export { PoolWorkers } from './pool-workers.js';
13
15
  export { PoolWarning } from './pool-warning.js';
14
16
  export { Resources } from './resources.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,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AmB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { type WallClock } from '@zukhruf/async';
2
+ import type { LeaderSelectorListener, Term } from '@zukhruf/election';
3
+ import type { Eviction } from './eviction.ts';
4
+ import type { PoolStats } from './pool-stats.ts';
5
+ import type { Sizing } from './sizing.ts';
6
+ import type { Startup } from './startup.ts';
7
+ import { type Store } from './store.ts';
8
+ import { type WorkerKind } from './worker-kind.ts';
9
+ import type { Worker } from './worker.ts';
10
+ /**
11
+ * What this host does with each term that it wins: it owns the workers of
12
+ * the kind until the term ends (ADR 0013). It takes as many jobs from the
13
+ * queue of its revision as it has free workers, runs each on a worker, and
14
+ * settles it with complete or fail (ADR 0017), so its sizing caps the jobs of
15
+ * its computer (ADR 0016). While a job runs, it touches the job every 5 s,
16
+ * and kills its worker when the store took the job back or the kind's time
17
+ * limit ends. The end of the term is a hand-over: it stops fetching, waits
18
+ * for the running jobs, resigns, and then closes the workers (ADR 0023).
19
+ */
20
+ export declare class Owner<Input, Output> implements LeaderSelectorListener {
21
+ #private;
22
+ constructor(options: {
23
+ kind: WorkerKind<Input, Output>;
24
+ store: Store;
25
+ clock: WallClock;
26
+ create: () => Worker<Input, Output>;
27
+ size: Sizing;
28
+ startup: Startup;
29
+ eviction: Eviction;
30
+ });
31
+ /** The slots of the term that runs: zero in each count while this host does not own. */
32
+ get stats(): PoolStats;
33
+ /**
34
+ * Resolves when the workers that the startup of the first term starts are
35
+ * ready, and rejects when one of them fails to start. It stays pending
36
+ * while this host never owned.
37
+ */
38
+ ready(): Promise<void>;
39
+ /** News of a new job of the kind: the owner fetches again. */
40
+ hear(): void;
41
+ /**
42
+ * Owns until `signal` aborts, and returns: the selector resigns the term
43
+ * after it. The resign of the hand-over comes before the workers close.
44
+ */
45
+ takeLeadership(term: Term, signal: AbortSignal): Promise<void>;
46
+ }
47
+ //# sourceMappingURL=owner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../src/owner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,SAAS,EAAS,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAKtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,KAAK,KAAK,EAAkB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuC1C;;;;;;;;;GASG;AACH,qBAAa,KAAK,CAAC,KAAK,EAAE,MAAM,CAAE,YAAW,sBAAsB;;IAmBjE,YAAY,OAAO,EAAE;QACnB,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,KAAK,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,SAAS,CAAC;QACjB,MAAM,EAAE,MAAM,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACpC,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,QAAQ,CAAC;KACpB,EAQA;IAED,wFAAwF;IACxF,IAAI,KAAK,IAAI,SAAS,CAErB;IAED;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;IAED,8DAA8D;IAC9D,IAAI,IAAI,IAAI,CAGX;IAED;;;OAGG;IACG,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCnE;CA6QF"}
package/dist/owner.js ADDED
@@ -0,0 +1,365 @@
1
+ import { Cond, Future, delay } from '@zukhruf/async';
2
+ import { isErrno } from '@zukhruf/fs';
3
+ import { NoServerError, PipeAddress } from '@zukhruf/pipes';
4
+ import { CallerPresence } from './caller-presence.js';
5
+ import { PoolWarning } from './pool-warning.js';
6
+ import { Slots } from './slots.js';
7
+ import { TOUCH_INTERVAL } from './store.js';
8
+ import { outputChannel } from './worker-kind.js';
9
+ // The read of the store that finds the jobs that no wake told of (ADR 0018).
10
+ const BACKSTOP = 1_000;
11
+ // The codes of a connection to a caller whose program is gone: the connection
12
+ // broke. A connect that finds the caller gone rejects with NoServerError.
13
+ const GONE = new Set(['ECONNRESET', 'EPIPE']);
14
+ const STANDBY = {
15
+ stats: () => ({ starting: 0, idle: 0, lent: 0, waiting: 0 }),
16
+ };
17
+ /**
18
+ * What this host does with each term that it wins: it owns the workers of
19
+ * the kind until the term ends (ADR 0013). It takes as many jobs from the
20
+ * queue of its revision as it has free workers, runs each on a worker, and
21
+ * settles it with complete or fail (ADR 0017), so its sizing caps the jobs of
22
+ * its computer (ADR 0016). While a job runs, it touches the job every 5 s,
23
+ * and kills its worker when the store took the job back or the kind's time
24
+ * limit ends. The end of the term is a hand-over: it stops fetching, waits
25
+ * for the running jobs, resigns, and then closes the workers (ADR 0023).
26
+ */
27
+ export class Owner {
28
+ #kind;
29
+ #store;
30
+ #clock;
31
+ #create;
32
+ #size;
33
+ #startup;
34
+ #eviction;
35
+ // Broadcasts when a run ends, the sizing changes, the backstop ends, or a
36
+ // host tells of a new job of the kind (ADR 0018).
37
+ #changed = new Cond();
38
+ // Counts the news of a new job. News that comes while a fetch reads the
39
+ // store finds no wait on the cond, so the owner compares the count from
40
+ // before the fetch, as pg-boss's worker checks beenNotified.
41
+ #heard = 0;
42
+ // Settles at the first term, by the startup of its workers.
43
+ #ready = new Future();
44
+ #role = STANDBY;
45
+ constructor(options) {
46
+ this.#kind = options.kind;
47
+ this.#store = options.store;
48
+ this.#clock = options.clock;
49
+ this.#create = options.create;
50
+ this.#size = options.size;
51
+ this.#startup = options.startup;
52
+ this.#eviction = options.eviction;
53
+ }
54
+ /** The slots of the term that runs: zero in each count while this host does not own. */
55
+ get stats() {
56
+ return this.#role.stats();
57
+ }
58
+ /**
59
+ * Resolves when the workers that the startup of the first term starts are
60
+ * ready, and rejects when one of them fails to start. It stays pending
61
+ * while this host never owned.
62
+ */
63
+ ready() {
64
+ return this.#ready.wait();
65
+ }
66
+ /** News of a new job of the kind: the owner fetches again. */
67
+ hear() {
68
+ this.#heard++;
69
+ this.#changed.broadcast();
70
+ }
71
+ /**
72
+ * Owns until `signal` aborts, and returns: the selector resigns the term
73
+ * after it. The resign of the hand-over comes before the workers close.
74
+ */
75
+ async takeLeadership(term, signal) {
76
+ if (signal.aborted)
77
+ return;
78
+ // Disposed last in, first out: the running jobs end, the term is
79
+ // resigned, the host counts as a standby, and then the workers close.
80
+ await using owned = new AsyncDisposableStack();
81
+ const slots = owned.use(new Slots({
82
+ size: this.#size,
83
+ startup: this.#startup,
84
+ eviction: this.#eviction,
85
+ create: this.#create,
86
+ clock: this.#clock,
87
+ resized: () => this.#changed.broadcast(),
88
+ }));
89
+ owned.defer(() => {
90
+ this.#role = STANDBY;
91
+ });
92
+ // A standby takes over before the workers close: a close can be slow.
93
+ owned.defer(() => term.resign());
94
+ const running = new Set();
95
+ owned.defer(async () => {
96
+ await Promise.all(running);
97
+ });
98
+ // The jobs that wait for this host's workers wait in the store, so no
99
+ // job waits in the host itself.
100
+ this.#role = { stats: () => slots.stats(0) };
101
+ slots.ready().then(() => this.#ready.resolve(), (error) => this.#ready.reject(error));
102
+ await this.#fetchUntil(signal, slots, running);
103
+ }
104
+ // Takes jobs for the free workers until the ownership ends.
105
+ async #fetchUntil(owning, slots, running) {
106
+ // Whether the last fetch took every job it asked for, so more may wait.
107
+ let backlog = false;
108
+ while (!owning.aborted) {
109
+ const free = this.#size.current - running.size;
110
+ const heard = this.#heard;
111
+ if (free > 0) {
112
+ // A fetch that fails waits for the backstop, as pg-boss's worker
113
+ // polls again after a failed fetch.
114
+ const jobs = await this.#store.queue
115
+ .fetch(this.#kind.queue, { batchSize: free })
116
+ .catch((error) => {
117
+ process.emitWarning(new PoolWarning(error, {
118
+ code: 'ZUKHRUF_POOL_FETCH_FAILED',
119
+ queue: this.#kind.queue,
120
+ }));
121
+ return [];
122
+ });
123
+ backlog = jobs.length === free;
124
+ for (const job of jobs) {
125
+ const run = this.#run(slots, job, () => backlog)
126
+ // A settle that fails leaves the job to lapse by its heartbeat,
127
+ // and the store runs it again by the kind's rules.
128
+ .catch((error) => process.emitWarning(new PoolWarning(error, {
129
+ code: 'ZUKHRUF_POOL_SETTLE_FAILED',
130
+ queue: this.#kind.queue,
131
+ job: job.id,
132
+ })))
133
+ .finally(() => {
134
+ running.delete(run);
135
+ this.#changed.broadcast();
136
+ });
137
+ running.add(run);
138
+ }
139
+ }
140
+ // A run that ended, a resize or news of a new job during the fetch
141
+ // broadcast before the rest began to wait, so check the free slots
142
+ // again in the same step.
143
+ if (this.#size.current - running.size > 0 &&
144
+ (backlog || this.#heard !== heard))
145
+ continue;
146
+ await this.#rest(owning);
147
+ }
148
+ }
149
+ // Waits for the next broadcast, or the end of the ownership. The backstop
150
+ // broadcasts too, so each rest is one wait that a broadcast ends, and no
151
+ // cancelled wait stays on the cond.
152
+ async #rest(owning) {
153
+ const backstop = this.#clock.setTimeout(() => this.#changed.broadcast(), BACKSTOP);
154
+ try {
155
+ await this.#changed.wait({ signal: owning });
156
+ }
157
+ catch (error) {
158
+ if (error !== owning.reason)
159
+ throw error;
160
+ }
161
+ finally {
162
+ this.#clock.clearTimeout(backstop);
163
+ }
164
+ }
165
+ // Runs one fetched job on a worker, and settles it by its attempt. A
166
+ // worker that fails to start fails the job, as the worker's own failure.
167
+ // The kind's time limit and the touches start at the fetch, as the store
168
+ // counts both from it, so a warm start counts too. At the time limit the
169
+ // owner kills the worker and fails the job; when the store took the job
170
+ // back, it kills the worker and settles nothing.
171
+ async #run(slots, job, backlog) {
172
+ const attempt = { id: job.id, retryCount: job.retryCount };
173
+ const slot = slots.lend();
174
+ const ended = new AbortController();
175
+ let connection;
176
+ try {
177
+ // A job of an exclusive kind may be shared, and a caller of a shared job
178
+ // that is gone only leaves it (ADR 0020).
179
+ const caller = this.#kind.policy === 'standard' ? callerOf(job.data) : undefined;
180
+ if (caller !== undefined) {
181
+ try {
182
+ connection = await new PipeAddress(caller).connect();
183
+ }
184
+ catch (error) {
185
+ if (!(error instanceof NoServerError))
186
+ throw error;
187
+ if (!this.#mayLive(caller, error)) {
188
+ // The caller is gone before its job starts: the job never runs.
189
+ await this.#forget(caller);
190
+ await this.#store.queue.cancel(this.#kind.queue, job.id);
191
+ return;
192
+ }
193
+ }
194
+ }
195
+ const callerEnds = [];
196
+ if (caller !== undefined) {
197
+ callerEnds.push(connection === undefined
198
+ ? this.#presenceEnds(caller, ended.signal)
199
+ : left(connection, this.#kind.queue));
200
+ }
201
+ const outcome = await Promise.race([
202
+ this.#work(slots, slot, job.data, backlog, ended.signal),
203
+ this.#watch(attempt, ended.signal),
204
+ ...callerEnds,
205
+ ]);
206
+ ended.abort();
207
+ if ('left' in outcome) {
208
+ await this.#forget(caller);
209
+ await this.#store.queue.cancel(this.#kind.queue, job.id);
210
+ }
211
+ // A settle that affects no row finds the job under another claim: the
212
+ // store fenced it, and the output is dropped (ADR 0017).
213
+ if ('output' in outcome)
214
+ await this.#store.queue.complete(this.#kind.queue, attempt, {
215
+ output: outcome.output,
216
+ });
217
+ else if ('failure' in outcome)
218
+ await this.#store.queue.fail(this.#kind.queue, attempt, failure(outcome.failure));
219
+ else if ('expired' in outcome)
220
+ await this.#store.queue.fail(this.#kind.queue, attempt,
221
+ // The error of pg-boss's work at the time limit (manager.js:606).
222
+ failure(new Error(`handler execution exceeded ${this.#kind.expireInSeconds}s`)));
223
+ // The store took a job that is gone back itself, and nobody waits for
224
+ // the output of a caller that left.
225
+ if (!('gone' in outcome) && !('left' in outcome))
226
+ this.#store.tell(outputChannel(this.#kind), job.id);
227
+ }
228
+ finally {
229
+ ended.abort();
230
+ connection?.destroy();
231
+ slots.release(slot);
232
+ }
233
+ }
234
+ // Linux refuses a connect only when no server listens, and a full listen
235
+ // queue gives EAGAIN. On macOS a live caller whose queue is full refuses
236
+ // too (kern.ipc.somaxconn, #5424), so its presence tells. The other codes
237
+ // find no caller at the address. A recorded copy of the #mayLive of
238
+ // @zukhruf/sqlite-notify's wakes.ts (docs/copied-code.md).
239
+ #mayLive(caller, error) {
240
+ if (process.platform === 'linux' || !isErrno(error.cause, 'ECONNREFUSED'))
241
+ return false;
242
+ return CallerPresence.lives(this.#store.path, caller);
243
+ }
244
+ // A caller that lives but refused the connect has no connection whose
245
+ // close tells of its end, so its presence is read at each touch instead.
246
+ async #presenceEnds(caller, ended) {
247
+ for (;;) {
248
+ await delay(TOUCH_INTERVAL, { clock: this.#clock, signal: ended });
249
+ if (!CallerPresence.lives(this.#store.path, caller))
250
+ return { left: true };
251
+ }
252
+ }
253
+ // Deletes the presence file of a caller that is gone. A caller that lives
254
+ // keeps it, and a removal that fails leaves it for the next owner that
255
+ // finds the caller gone.
256
+ async #forget(caller) {
257
+ try {
258
+ await CallerPresence.removeIfEnded(this.#store.path, caller, this.#clock);
259
+ }
260
+ catch (error) {
261
+ process.emitWarning(new PoolWarning(error, {
262
+ code: 'ZUKHRUF_POOL_CALLER_PRESENCE_REMOVE_FAILED',
263
+ queue: this.#kind.queue,
264
+ }));
265
+ }
266
+ }
267
+ // Runs the input on the worker of the slot. The end of the run kills the
268
+ // worker of a run that has not ended, and leaves its outcome unread.
269
+ async #work(slots, slot, data, backlog, ended) {
270
+ let worker;
271
+ try {
272
+ worker = await slots.borrow(slot);
273
+ }
274
+ catch (error) {
275
+ return { failure: error };
276
+ }
277
+ if (ended.aborted)
278
+ return { gone: true };
279
+ const kill = () => slots.kill(slot, worker);
280
+ ended.addEventListener('abort', kill, { once: true });
281
+ const started = this.#clock.performance.now();
282
+ try {
283
+ if (!isEnvelope(data))
284
+ throw new TypeError('The job has no input: no Pool sent it.');
285
+ return { output: await worker.run(data.input) };
286
+ }
287
+ catch (error) {
288
+ return { failure: error };
289
+ }
290
+ finally {
291
+ ended.removeEventListener('abort', kill);
292
+ if (!ended.aborted)
293
+ slots.record(started, backlog());
294
+ }
295
+ }
296
+ // Touches the job every 5 s until the run ends, and resolves when the
297
+ // kind's time limit ends or a touch finds that the store took the job back.
298
+ async #watch(attempt, ended) {
299
+ const deadline = this.#clock.performance.now() + this.#kind.expireInSeconds * 1_000;
300
+ for (;;) {
301
+ const remaining = deadline - this.#clock.performance.now();
302
+ if (remaining <= 0)
303
+ return { expired: true };
304
+ await delay(Math.min(TOUCH_INTERVAL, remaining), {
305
+ clock: this.#clock,
306
+ signal: ended,
307
+ });
308
+ if (this.#clock.performance.now() >= deadline)
309
+ return { expired: true };
310
+ let affected;
311
+ try {
312
+ ({ affected } = await this.#store.queue.touch(this.#kind.queue, attempt));
313
+ }
314
+ catch (error) {
315
+ // The job keeps its worker, and the next touch tries again.
316
+ process.emitWarning(new PoolWarning(error, {
317
+ code: 'ZUKHRUF_POOL_TOUCH_FAILED',
318
+ queue: this.#kind.queue,
319
+ job: attempt.id,
320
+ }));
321
+ continue;
322
+ }
323
+ if (affected === 0)
324
+ return { gone: true };
325
+ }
326
+ }
327
+ }
328
+ // The pool does not check the input itself: a sender and an owner of one
329
+ // revision run the same code (ADR 0014).
330
+ function isEnvelope(data) {
331
+ return typeof data === 'object' && data !== null && 'input' in data;
332
+ }
333
+ // The pipe of the caller that a run wrote on its job, if any.
334
+ function callerOf(data) {
335
+ return isEnvelope(data) && typeof data.caller === 'string'
336
+ ? data.caller
337
+ : undefined;
338
+ }
339
+ function isGone(error) {
340
+ return (Error.isError(error) &&
341
+ 'code' in error &&
342
+ typeof error.code === 'string' &&
343
+ GONE.has(error.code));
344
+ }
345
+ // Resolves when the connection to the caller closes: its program is gone, or
346
+ // its Pool was disposed. A break of the connection only ends it.
347
+ function left(connection, queue) {
348
+ connection.on('error', (error) => {
349
+ if (!isGone(error))
350
+ process.emitWarning(new PoolWarning(error, {
351
+ code: 'ZUKHRUF_POOL_CALLER_CONNECTION_ERROR',
352
+ queue,
353
+ }));
354
+ });
355
+ return new Promise((resolve) => {
356
+ connection.once('close', () => resolve({ left: true }));
357
+ });
358
+ }
359
+ /** A failure as data: its name and its message (ADR 0019). */
360
+ function failure(error) {
361
+ return Error.isError(error)
362
+ ? { name: error.name, message: error.message }
363
+ : { name: 'Error', message: String(error) };
364
+ }
365
+ //# sourceMappingURL=owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner.js","sourceRoot":"","sources":["../src/owner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAkB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAa,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAmB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGlE,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,K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