@zukhruf/single-flight 0.8.17 → 0.8.19

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
@@ -70,14 +70,14 @@ The lease that the work gets comes from `@zukhruf/lease`, and its token comes fr
70
70
 
71
71
  ## The directory
72
72
 
73
- The directory is the local folder where the processes that share flights meet. Each process that uses a `SingleFlight` keeps three files and a folder there: `flight.lock`, `flight.epoch`, `flight.sock` and `execution-locks/`. The election of [`@zukhruf/election`](../election/README.md) claims `flight.lock` with a file lock, and records the epoch of the last term in `flight.epoch`. The folder `execution-locks/` has one file for each key that ever led: the key lock of that key, named by the SHA-256 of the key. The process that runs the work of a key holds a file lock on that file (see [When a process stops](#when-a-process-stops)). The files stay after the flights, so do not remove them while a process uses the directory. The journal of the claim is in memory, so a coordinator that stops leaves no `flight.lock-journal` file. All the processes that name the same directory are one group, and the callers of one key share a flight in that group only.
73
+ The directory is the local folder where the processes that share flights meet. Each process that uses a `SingleFlight` keeps five files and a folder there: `flight.lock`, `flight.lock.leader`, `flight.lock.clean`, `flight.epoch`, `flight.sock` and `execution-locks/`. The leader writes its process id and the address of its pipe to `flight.lock.leader`, and a term that resigns cleanly writes `flight.lock.clean`, which the next term reads and removes. The election of [`@zukhruf/election`](../election/README.md) claims `flight.lock` with a file lock, and records the epoch of the last term in `flight.epoch`. The folder `execution-locks/` has one file for each key that ever led: the key lock of that key, named by the SHA-256 of the key. The process that runs the work of a key holds a file lock on that file (see [When a process stops](#when-a-process-stops)). The files stay after the flights, so do not remove them while a process uses the directory. The journal of the claim is in memory, so a coordinator that stops leaves no `flight.lock-journal` file. All the processes that name the same directory are one group, and the callers of one key share a flight in that group only.
74
74
 
75
75
  Each `SingleFlight` also takes a `clock`: the clock of the waits of the group, for example the wait for a key lock. Give `globalThis` in production. A test gives a fake clock, for example `createClock()` of `@sinonjs/fake-timers` ([`@zukhruf/async`](../async/README.md#run-a-wait-on-a-clock)).
76
76
 
77
77
  There is no default directory. One default would put each application on the host into one group, and unrelated applications that use the same key would join each other's flights. Give each group its own directory, for example a folder of your application's data.
78
78
 
79
79
  - The directory must be on a local file system. On a network file system, a call rejects with `NetworkDirectoryError`.
80
- - On macOS and Linux, the path of `flight.sock` must have 103 bytes or fewer. A longer path throws a `RangeError` when you create the `SingleFlight`. On Windows, the socket is a named pipe, and the length of the directory does not matter.
80
+ - The absolute path of `flight.sock` must have 103 bytes or fewer on macOS, and 107 bytes or fewer on Linux. [`@zukhruf/pipes`](../pipes/README.md) checks it: a longer path throws a `RangeError` when you create the `SingleFlight`. On Windows, the socket is the named pipe `\\.\pipe\zukhruf-single-flight-<hash of the socket path>`, and the length of the directory does not matter.
81
81
  - A single flight and a socket lock store of `@zukhruf/mutex` can use one directory. They use different files, and they never meet.
82
82
 
83
83
  ## Run a flight
@@ -91,10 +91,11 @@ The work gets the lease of the flight:
91
91
  - `token`: a `FencingToken`. Its high 32 bits are the epoch of the coordinator's term, so a newer term always gives higher tokens.
92
92
  - `signal`: it aborts with `LeaseLostError` when the flight is no longer the leader's, so its outcome reaches no joiner. The `subject` of the error is the key. This occurs when a new coordinator refuses the reassert of the leader, because it knows a newer flight of the key, or when this process cannot connect to a coordinator again.
93
93
 
94
- | Option | What it does |
95
- | ----------- | --------------------------------------------------------------------------------------------- |
96
- | `directory` | The local folder where the processes of one group meet. See [The directory](#the-directory). |
97
- | `codec` | Turns the value of a flight into text for the joiners, and back. See [The codec](#the-codec). |
94
+ | Option | What it does |
95
+ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96
+ | `directory` | The local folder where the processes of one group meet. See [The directory](#the-directory). |
97
+ | `codec` | Turns the value of a flight into text for the joiners, and back. See [The codec](#the-codec). |
98
+ | `leaseDuration` | The longest silence, in milliseconds, that the other processes accept from this process while it is the coordinator. See [When a process stops](#when-a-process-stops). The default is 15000. |
98
99
 
99
100
  `flights[Symbol.asyncDispose]()` waits until each landing of this process reached a coordinator, and then it disconnects. When this process is the coordinator, the other processes elect a new one. The work of a flight that this process leads continues, and this process keeps the key lock of that key until the work ends.
100
101
 
@@ -179,7 +180,8 @@ A leader keeps its flight while its process lives. Before its work starts, the l
179
180
  - Each joiner rejoins its flight by the flight's token, and it gets the outcome of that flight.
180
181
  - A new call of a key that no process holds leads or joins at once.
181
182
  - A new call or a rejoin of a key whose key lock another process holds, while the new coordinator knows no flight of the key, waits. When the leader reasserts its flight, the call or the rejoin joins it. When the key lock frees first, the call leads, and the rejoin gets `FlightInterruptedError`.
182
- - **A leader is frozen or busy, for example stopped by a debugger or in a long synchronous step.** It keeps its flight and its key lock. When the coordinator stops in that time, the calls of the key wait. When the leader continues, it reasserts its flight, and the calls that waited join it. When its process dies instead, the kernel frees the key lock, the joiners get `FlightInterruptedError`, and the next call leads.
183
+ - **The coordinator is frozen or busy past its lease duration, for example stopped by a debugger or in a long synchronous step.** The coordinator sends a heartbeat on the pipe of its election. A process that hears no heartbeat for longer than the `leaseDuration` of the coordinator ends the process of the coordinator. Then the other processes elect a new coordinator, as when the coordinator stops. Set `leaseDuration` above the longest pause of your processes. [ADR 0011](./docs/adr/0011-a-follower-observes-the-coordinator-so-a-frozen-coordinator-is-ended.md) tells why.
184
+ - **A leader is frozen or busy, for example stopped by a debugger or in a long synchronous step.** When its process is not the coordinator, it keeps its flight and its key lock. When the coordinator stops in that time, the calls of the key wait. When the leader continues, it reasserts its flight, and the calls that waited join it. When its process dies instead, the kernel frees the key lock, the joiners get `FlightInterruptedError`, and the next call leads. When its process is the coordinator, a process ends it after the lease duration, as the item above tells, with the same result.
183
185
  - **A leader loses its lease.** This occurs only when a new coordinator refuses its reassert, because it knows a newer flight of the key, or when this process cannot connect to a coordinator again. The signal of the lease aborts with `LeaseLostError`, and the call of the leader rejects with that error. When the work throws its own error after the loss, the call rejects with a new `LeaseLostError`, and the error of the work is its `cause`. Thus `LeaseLostError` tells the leader that its outcome reached no joiner. Its joiners get `FlightInterruptedError`. The leader keeps the key lock until its work ends, so the next flight of the key runs after it, not beside it. [ADR 0007](./docs/adr/0007-a-work-error-after-a-lost-lease-rejects-with-leaselosterror.md) tells why.
184
186
  - **A joiner's leader and the coordinator stop together.** The joiner gets `FlightInterruptedError` from the new coordinator. It never runs the work again.
185
187
 
@@ -212,6 +214,7 @@ Version 0.3.13 to 0.3.15 had a pull design. These parts changed:
212
214
  - [ADR 0007: A work error after a lost lease rejects with LeaseLostError](./docs/adr/0007-a-work-error-after-a-lost-lease-rejects-with-leaselosterror.md)
213
215
  - [ADR 0008: A connection closes only when its framing breaks](./docs/adr/0008-a-connection-closes-only-when-its-framing-breaks.md)
214
216
  - [ADR 0010: A leader holds a kernel lock on its key until its outcome is handed over](./docs/adr/0010-a-leader-holds-a-kernel-lock-on-its-key-until-its-outcome-is-handed-over.md)
217
+ - [ADR 0011: A follower observes the coordinator, so a frozen coordinator is ended](./docs/adr/0011-a-follower-observes-the-coordinator-so-a-frozen-coordinator-is-ended.md)
215
218
  - [Code copied from the mutex](./docs/copied-from-mutex.md): each copied file, what changed, and why; the rules that the single flight shares with the mutex; and the code that is in two places inside the single flight.
216
219
  - Superseded: [ADR 0001](./docs/adr/0001-a-joiner-follows-its-flight-record-without-acquiring-the-key.md), [ADR 0002](./docs/adr/0002-a-flight-that-all-callers-left-is-abandoned.md) and [ADR 0009](./docs/adr/0009-the-next-coordinator-skips-the-grace-window-after-a-clean-shutdown.md).
217
220
 
@@ -1,12 +1,13 @@
1
1
  import { type Clock } from '@zukhruf/async';
2
- import type { LeaderElection, Term } from '@zukhruf/election';
2
+ import type { SqliteElection, Term } from '@zukhruf/election';
3
+ import type { PipeAddress } from '@zukhruf/pipes';
3
4
  import type { FlightConnection, FlightConnector } from './connector.ts';
4
5
  export interface ElectingConnectorOptions {
5
- socketPath: string;
6
- /** Only `campaign`: the connector never runs a backend's own steps, so an election of any backend fits. */
7
- election: Pick<LeaderElection<unknown>, 'campaign'>;
8
- pollInterval: number;
9
- /** The clock of the waits. */
6
+ /** Where the coordinator listens. */
7
+ address: PipeAddress;
8
+ /** One try of the claim, and an observer of the coordinator (election ADR 0009). */
9
+ election: Pick<SqliteElection, 'campaign' | 'observe'>;
10
+ /** The clock of the back-off between two tries. */
10
11
  clock: Clock;
11
12
  /** Starts serving for a term this process just won. */
12
13
  serve(term: Term): Promise<void>;
@@ -14,7 +15,9 @@ export interface ElectingConnectorOptions {
14
15
  /**
15
16
  * Reaches the coordinator's socket, and when nobody serves it, campaigns to
16
17
  * become the coordinator. Never gives up: a lost coordinator is always
17
- * replaced by a candidate. An aborted connect never starts serving: a term
18
+ * replaced by a candidate. A follower observes the coordinator, so a
19
+ * coordinator that is silent past its lease duration is ended and replaced
20
+ * too (election ADR 0009). An aborted connect never starts serving: a term
18
21
  * won after the abort is resigned.
19
22
  */
20
23
  export declare class ElectingConnector implements FlightConnector {
@@ -1 +1 @@
1
- {"version":3,"file":"electing-connector.d.ts","sourceRoot":"","sources":["../../src/connection/electing-connector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKxE,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,uDAAuD;IACvD,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,eAAe;;gBAG3C,OAAO,EAAE,wBAAwB;IAIvC,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAuF9D"}
1
+ {"version":3,"file":"electing-connector.d.ts","sourceRoot":"","sources":["../../src/connection/electing-connector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAkB,cAAc,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKxE,MAAM,WAAW,wBAAwB;IACvC,qCAAqC;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,oFAAoF;IACpF,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;IACvD,mDAAmD;IACnD,KAAK,EAAE,KAAK,CAAC;IACb,uDAAuD;IACvD,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAeD;;;;;;;GAOG;AACH,qBAAa,iBAAkB,YAAW,eAAe;;gBAG3C,OAAO,EAAE,wBAAwB;IAIvC,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA+G9D"}
@@ -1,13 +1,25 @@
1
- import { once } from 'node:events';
2
- import { connect } from 'node:net';
3
- import { delay, untilAborted } from '@zukhruf/async';
1
+ import { Backoff, delay, untilAborted } from '@zukhruf/async';
4
2
  import { PROTOCOL_VERSION, greet } from "./handshake.js";
5
3
  import { ProtocolVersionError } from "./protocol-version-error.js";
6
4
  import { SocketConnection } from "./socket-connection.js";
5
+ /**
6
+ * The wait after a lost try while the server of the new coordinator is not
7
+ * reachable yet: the back-off of the election, etcd's first retry of 25 ms,
8
+ * gRPC's multiplier of 1.6 and jitter of ±20 %, at most 1000 ms (election
9
+ * ADR 0007).
10
+ */
11
+ const backoff = new Backoff({
12
+ initial: 25,
13
+ multiplier: 1.6,
14
+ max: 1000,
15
+ jitter: { kind: 'ratio', ratio: 0.2 },
16
+ });
7
17
  /**
8
18
  * Reaches the coordinator's socket, and when nobody serves it, campaigns to
9
19
  * become the coordinator. Never gives up: a lost coordinator is always
10
- * replaced by a candidate. An aborted connect never starts serving: a term
20
+ * replaced by a candidate. A follower observes the coordinator, so a
21
+ * coordinator that is silent past its lease duration is ended and replaced
22
+ * too (election ADR 0009). An aborted connect never starts serving: a term
11
23
  * won after the abort is resigned.
12
24
  */
13
25
  export class ElectingConnector {
@@ -16,23 +28,24 @@ export class ElectingConnector {
16
28
  this.#options = options;
17
29
  }
18
30
  async connect(signal) {
19
- const { socketPath, pollInterval, clock } = this.#options;
31
+ const { address, election, clock } = this.#options;
32
+ using betweenTries = new BetweenTries(election, clock);
20
33
  for (;;) {
21
- const coordinator = await reachUnlessAborted(socketPath, signal);
34
+ const coordinator = await reachUnlessAborted(address, signal);
22
35
  if (coordinator) {
23
36
  const connection = (await this.#follow(coordinator, signal)) ??
24
- (await this.#outlastHangUp(signal));
37
+ (await this.#outlastHangUp(betweenTries, signal));
25
38
  if (connection)
26
39
  return connection;
27
40
  }
28
- const term = await this.#campaign(pollInterval, signal);
41
+ const term = await this.#campaign(signal);
29
42
  if (term) {
30
43
  const own = await this.#coordinate(term, signal);
31
44
  if (own)
32
45
  return own;
33
46
  }
34
47
  else {
35
- await delay(pollInterval, { clock, signal });
48
+ await betweenTries.wait(signal);
36
49
  }
37
50
  }
38
51
  }
@@ -42,28 +55,27 @@ export class ElectingConnector {
42
55
  * successor at once, and reasserts its flights. Resolves `undefined` once
43
56
  * nothing listens.
44
57
  */
45
- async #outlastHangUp(signal) {
46
- const { socketPath, pollInterval, clock } = this.#options;
58
+ async #outlastHangUp(betweenTries, signal) {
47
59
  for (;;) {
48
- const term = await this.#campaign(0, signal);
60
+ const term = await this.#campaign(signal);
49
61
  if (term)
50
62
  return this.#coordinate(term, signal);
51
- const again = await reachUnlessAborted(socketPath, signal);
63
+ const again = await reachUnlessAborted(this.#options.address, signal);
52
64
  if (!again)
53
65
  return undefined;
54
66
  const connection = await this.#follow(again, signal);
55
67
  if (connection)
56
68
  return connection;
57
- await delay(pollInterval, { clock, signal });
69
+ await betweenTries.wait(signal);
58
70
  }
59
71
  }
60
72
  /**
61
- * Campaigns until `timeout`; a term won after `signal` aborted is resigned.
73
+ * Tries the claim once; a term won after `signal` aborted is resigned.
62
74
  * The election gives up a term that it wins after the abort, but the abort
63
75
  * can also land after the campaign resolved, before this step continues.
64
76
  */
65
- async #campaign(timeout, signal) {
66
- const term = await this.#options.election.campaign({ timeout, signal });
77
+ async #campaign(signal) {
78
+ const term = await this.#options.election.campaign({ signal });
67
79
  if (signal.aborted)
68
80
  await term?.resign();
69
81
  signal.throwIfAborted();
@@ -76,7 +88,7 @@ export class ElectingConnector {
76
88
  serving.defer(() => term.resign());
77
89
  await this.#options.serve(term);
78
90
  serving.move();
79
- const own = await reachUnlessAborted(this.#options.socketPath, signal);
91
+ const own = await reachUnlessAborted(this.#options.address, signal);
80
92
  if (!own)
81
93
  return undefined;
82
94
  const greeting = await greetUnlessAborted(own, signal);
@@ -87,7 +99,9 @@ export class ElectingConnector {
87
99
  }
88
100
  /** Uses the coordinator on `socket` if it speaks this protocol; `undefined` when it hung up on the hello. */
89
101
  async #follow(socket, signal) {
90
- const greeting = await greetUnlessAborted(socket, signal);
102
+ const greeted = new AbortController();
103
+ this.#observeCoordinator(socket, greeted.signal);
104
+ const greeting = await greetUnlessAborted(socket, signal).finally(() => greeted.abort());
91
105
  if (greeting.kind === 'welcome')
92
106
  return flightConnection(socket);
93
107
  socket.destroy();
@@ -96,30 +110,111 @@ export class ElectingConnector {
96
110
  }
97
111
  return undefined;
98
112
  }
113
+ /**
114
+ * Observes the coordinator until `socket` closes, so a coordinator that
115
+ * goes silent is ended (election ADR 0009). A coordinator that leaves
116
+ * before `greeted` aborts takes `socket` with it, as a hang-up does. After
117
+ * the welcome, the kernel closes `socket` when the process of the
118
+ * coordinator ends, and the supervisor reconnects as after each death of a
119
+ * coordinator. A coordinator that this process cannot observe, such as one
120
+ * of a published version, which serves no pipe, is followed as before:
121
+ * nothing can take its place while it lives.
122
+ */
123
+ #observeCoordinator(socket, greeted) {
124
+ const observer = this.#options.election.observe();
125
+ socket.once('close', () => observer[Symbol.dispose]());
126
+ observer.left.then((reason) => {
127
+ if (reason !== 'absent' && !greeted.aborted)
128
+ socket.destroy();
129
+ },
130
+ // An observer that fails leaves the coordinator as one that serves no pipe is: followed.
131
+ () => { });
132
+ }
133
+ }
134
+ /**
135
+ * The wait after a lost try, while the server of the new coordinator is not
136
+ * reachable yet: the first of the coordinator's leave and the next step of
137
+ * the back-off (election ADR 0009). One observer lasts across the steps
138
+ * until it settles, so it also ends a coordinator that hung before its
139
+ * server listened.
140
+ */
141
+ class BetweenTries {
142
+ #election;
143
+ #clock;
144
+ #watch = new Unwatched();
145
+ #retries = 0;
146
+ constructor(election, clock) {
147
+ this.#election = election;
148
+ this.#clock = clock;
149
+ }
150
+ /** Rejects with `signal.reason`, or with an error of the observer. */
151
+ async wait(signal) {
152
+ const watching = (this.#watch = this.#watch.watch(this.#election));
153
+ const stepped = new AbortController();
154
+ const step = delay(backoff.duration(this.#retries++), {
155
+ clock: this.#clock,
156
+ signal: AbortSignal.any([signal, stepped.signal]),
157
+ });
158
+ const left = watching.observer.left.then((reason) => {
159
+ this.#settled(watching);
160
+ // No pipe to watch: a new coordinator is starting, so only the step can tell.
161
+ if (reason === 'absent')
162
+ return step;
163
+ this.#retries = 0;
164
+ });
165
+ try {
166
+ await Promise.race([step, left]);
167
+ }
168
+ finally {
169
+ stepped.abort();
170
+ }
171
+ }
172
+ /** The next wait observes again. */
173
+ #settled(watching) {
174
+ if (this.#watch !== watching)
175
+ return;
176
+ watching[Symbol.dispose]();
177
+ this.#watch = new Unwatched();
178
+ }
179
+ [Symbol.dispose]() {
180
+ this.#watch[Symbol.dispose]();
181
+ }
182
+ }
183
+ /** No observer: before the first wait of a connect, and after an observer settled. */
184
+ class Unwatched {
185
+ watch(election) {
186
+ return new Watching(election.observe());
187
+ }
188
+ [Symbol.dispose]() { }
189
+ }
190
+ /** An observer that has not settled yet. */
191
+ class Watching {
192
+ observer;
193
+ constructor(observer) {
194
+ this.observer = observer;
195
+ }
196
+ watch() {
197
+ return this;
198
+ }
199
+ [Symbol.dispose]() {
200
+ this.observer[Symbol.dispose]();
201
+ }
99
202
  }
100
203
  function flightConnection(socket) {
101
204
  return new SocketConnection(socket);
102
205
  }
103
206
  /** Like `reach`, but a socket reached after `signal` aborted is destroyed, not returned. */
104
- async function reachUnlessAborted(socketPath, signal) {
207
+ async function reachUnlessAborted(address, signal) {
105
208
  signal.throwIfAborted();
106
- const socket = await reach(socketPath);
209
+ const socket = await reach(address);
107
210
  if (signal.aborted)
108
211
  socket?.destroy();
109
212
  signal.throwIfAborted();
110
213
  return socket;
111
214
  }
112
215
  /** Resolves `undefined` when nothing listens yet (no file, or a dead coordinator's file). */
113
- async function reach(socketPath) {
114
- const socket = connect(socketPath);
115
- try {
116
- await once(socket, 'connect');
117
- return socket;
118
- }
119
- catch {
120
- socket.destroy();
121
- return undefined;
122
- }
216
+ async function reach(address) {
217
+ return address.connect().catch(() => undefined);
123
218
  }
124
219
  /** Greets the coordinator on `socket`; a client that closes meanwhile gives the socket up. */
125
220
  async function greetUnlessAborted(socket, signal) {
@@ -1 +1 @@
1
- {"version":3,"file":"electing-connector.js","sourceRoot":"","sources":["../../src/connection/electing-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAe,OAAO,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAc,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKjE,OAAO,EAAiB,gBAAgB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO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UAAU,KAAK,CAAC,OAAoB;IACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AAED,8FAA8F;AAC9F,KAAK,UAAU,kBAAkB,CAC/B,MAAc,EACd,MAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1D,QAAQ,CAAC,IAAI,EAAE,CAAC;IAChB,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -8,5 +8,5 @@ import { SqliteElection } from '@zukhruf/election';
8
8
  * `@zukhruf/mutex` names its files `leader.*`, so it never joins this
9
9
  * election in a shared directory.
10
10
  */
11
- export declare function flightElection(directory: string, pollInterval: number, clock: Clock): SqliteElection;
11
+ export declare function flightElection(directory: string, clock: Clock, leaseDuration?: number): SqliteElection;
12
12
  //# sourceMappingURL=flight-election.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flight-election.d.ts","sourceRoot":"","sources":["../../src/connection/flight-election.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,KAAK,GACX,cAAc,CAQhB"}
1
+ {"version":3,"file":"flight-election.d.ts","sourceRoot":"","sources":["../../src/connection/flight-election.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,EACZ,aAAa,CAAC,EAAE,MAAM,GACrB,cAAc,CAQhB"}
@@ -7,12 +7,12 @@ import { SqliteElection } from '@zukhruf/election';
7
7
  * `@zukhruf/mutex` names its files `leader.*`, so it never joins this
8
8
  * election in a shared directory.
9
9
  */
10
- export function flightElection(directory, pollInterval, clock) {
10
+ export function flightElection(directory, clock, leaseDuration) {
11
11
  return new SqliteElection({
12
12
  directory,
13
13
  claimFile: 'flight.lock',
14
14
  epochFile: 'flight.epoch',
15
- pollInterval,
15
+ leaseDuration,
16
16
  clock,
17
17
  });
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flight-election.js","sourceRoot":"","sources":["../../src/connection/flight-election.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,SAAiB,EACjB,YAAoB,EACpB,KAAY;IAEZ,OAAO,IAAI,cAAc,CAAC;QACxB,SAAS;QACT,SAAS,EAAE,aAAa;QACxB,SAAS,EAAE,cAAc;QACzB,YAAY;QACZ,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"flight-election.js","sourceRoot":"","sources":["../../src/connection/flight-election.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,SAAiB,EACjB,KAAY,EACZ,aAAsB;IAEtB,OAAO,IAAI,cAAc,CAAC;QACxB,SAAS;QACT,SAAS,EAAE,aAAa;QACxB,SAAS,EAAE,cAAc;QACzB,aAAa;QACb,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { Term } from '@zukhruf/election';
2
+ import type { PipeEndpoint } from '@zukhruf/pipes';
2
3
  import type { KeyLocks } from '../key-lock/key-locks.ts';
3
4
  export interface FlightServerOptions {
4
5
  /** The kernel locks on the keys, which the coordinator checks before a run leads. */
@@ -13,7 +14,7 @@ export interface FlightServerOptions {
13
14
  export declare class FlightServer {
14
15
  #private;
15
16
  private constructor();
16
- static start(socketPath: string, term: Term, { locks }: FlightServerOptions): Promise<FlightServer>;
17
+ static start(endpoint: PipeEndpoint, term: Term, { locks }: FlightServerOptions): Promise<FlightServer>;
17
18
  /**
18
19
  * Hands the term over. Ending every connection tells the other processes to
19
20
  * elect a successor and reassert their flights to it; `close` alone would
@@ -1 +1 @@
1
- {"version":3,"file":"flight-server.d.ts","sourceRoot":"","sources":["../../src/coordinator/flight-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAK9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;;IAOvB,OAAO;WAaM,KAAK,CAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,IAAI,EACV,EAAE,KAAK,EAAE,EAAE,mBAAmB,GAC7B,OAAO,CAAC,YAAY,CAAC;IAuCxB;;;;;;;;;;OAUG;IACG,KAAK;CAQZ"}
1
+ {"version":3,"file":"flight-server.d.ts","sourceRoot":"","sources":["../../src/coordinator/flight-server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,gBAAgB,CAAC;AAI/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;;IAOvB,OAAO;WAaM,KAAK,CAChB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,IAAI,EACV,EAAE,KAAK,EAAE,EAAE,mBAAmB,GAC7B,OAAO,CAAC,YAAY,CAAC;IAiCxB;;;;;;;;;;OAUG;IACG,KAAK;CAQZ"}
@@ -1,6 +1,4 @@
1
- import { addAbortListener, once } from 'node:events';
2
- import { rm } from 'node:fs/promises';
3
- import { createServer } from 'node:net';
1
+ import { addAbortListener } from 'node:events';
4
2
  import { EpochTokenSource } from '@zukhruf/fencing';
5
3
  import { welcome } from "../connection/handshake.js";
6
4
  import { SocketConnection } from "../connection/socket-connection.js";
@@ -24,12 +22,7 @@ export class FlightServer {
24
22
  this.#term = term;
25
23
  this.#closeOnLoss = addAbortListener(term.signal, () => void this.close());
26
24
  }
27
- static async start(socketPath, term, { locks }) {
28
- // Only the coordinator gets here, so removing a dead coordinator's socket file cannot race another server.
29
- // Windows removes a named pipe when its process stops, so there is no file to remove.
30
- if (process.platform !== 'win32') {
31
- await rm(socketPath, { force: true });
32
- }
25
+ static async start(endpoint, term, { locks }) {
33
26
  const coordinator = new FlightCoordinator({
34
27
  tokens: new EpochTokenSource(term.epoch),
35
28
  locks,
@@ -40,8 +33,9 @@ export class FlightServer {
40
33
  onTokensExhausted: () => void started.close(),
41
34
  });
42
35
  const connections = new Set();
36
+ // Only the coordinator gets here, so the listen that removes a dead coordinator's socket file cannot race another server.
43
37
  // Serving others never keeps the coordinator alive: when its own work ends, it exits and another process takes over.
44
- const server = createServer((socket) => {
38
+ const server = await endpoint.listen((socket) => {
45
39
  socket.unref();
46
40
  connections.add(socket);
47
41
  socket.once('close', () => connections.delete(socket));
@@ -52,8 +46,6 @@ export class FlightServer {
52
46
  coordinator.serve(new SocketConnection(socket));
53
47
  });
54
48
  });
55
- server.listen(socketPath);
56
- await once(server, 'listening');
57
49
  server.unref();
58
50
  const started = new FlightServer(server, connections, coordinator, term);
59
51
  // The term may have been lost while the server started.
@@ -77,7 +69,7 @@ export class FlightServer {
77
69
  async close() {
78
70
  this.#closeOnLoss[Symbol.dispose]();
79
71
  this.#coordinator.close();
80
- const closed = this.#server[Symbol.asyncDispose]();
72
+ const closed = this.#server.close();
81
73
  for (const socket of this.#connections)
82
74
  socket.destroySoon();
83
75
  await closed;
@@ -1 +1 @@
1
- {"version":3,"file":"flight-server.js","sourceRoot":"","sources":["../../src/coordinator/flight-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAA4B,YAAY,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO5D;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACd,OAAO,CAAS;IAChB,YAAY,CAAc;IAC1B,YAAY,CAAoB;IAChC,KAAK,CAAO;IACZ,YAAY,CAAa;IAElC,YACE,MAAc,EACd,WAAwB,EACxB,WAA8B,EAC9B,IAAU;QAEV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK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QACL,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QACzE,wDAAwD;QACxD,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,MAAM,CAAC;QACb,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -16,6 +16,14 @@ export interface SingleFlightOptions<T> {
16
16
  codec: Codec<T>;
17
17
  /** The clock of every wait of the group: `globalThis` in production, a fake clock in a test. */
18
18
  clock: Clock;
19
+ /**
20
+ * The longest silence, in milliseconds, that the other processes accept
21
+ * from this process while it is the coordinator. A process ends a
22
+ * coordinator that is silent for longer, for example one stopped with
23
+ * SIGSTOP, and a survivor takes over. The default is the one of
24
+ * `SqliteElection`.
25
+ */
26
+ leaseDuration?: number;
19
27
  }
20
28
  export interface RunOptions {
21
29
  /** Called once, when this caller joins a flight that another caller leads. */
@@ -37,7 +45,7 @@ export interface FlightValue<T> {
37
45
  */
38
46
  export declare class SingleFlight<T> implements AsyncDisposable {
39
47
  #private;
40
- constructor({ directory, codec, clock }: SingleFlightOptions<T>);
48
+ constructor({ directory, codec, clock, leaseDuration, }: SingleFlightOptions<T>);
41
49
  /**
42
50
  * Runs `work` for `key` as the leader of a new flight, or joins the flight
43
51
  * of `key` in progress. `work` gets the flight's lease: its token, and a
@@ -1 +1 @@
1
- {"version":3,"file":"single-flight.d.ts","sourceRoot":"","sources":["../src/single-flight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAqBxC,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC;;;;;;;;OAQG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAChB,gGAAgG;IAChG,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClC,uGAAuG;IACvG,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAED,mHAAmH;AACnH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAKD;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,CAAC,CAAE,YAAW,eAAe;;gBAMzC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAmC/D;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACxC,EAAE,MAAM,E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AC,CAAC,EACxC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAE,UAAe,GAClC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAmB1B,gGAAgG;IAC1F,CAAC,MAAM,CAAC,YAAY,CAAC;CAuC5B"}
@@ -1,15 +1,16 @@
1
+ import { resolve } from 'node:path';
1
2
  import { untilAborted } from '@zukhruf/async';
2
3
  import { LeaseLostError } from '@zukhruf/lease';
4
+ import { PipeEndpoint } from '@zukhruf/pipes';
3
5
  import { FlightClient } from "./client/flight-client.js";
4
6
  import { ConnectionSupervisor } from "./connection/connection-supervisor.js";
5
7
  import { ElectingConnector } from "./connection/electing-connector.js";
6
8
  import { flightElection } from "./connection/flight-election.js";
7
9
  import { LocalDirectoryConnector } from "./connection/local-directory-connector.js";
8
- import { socketPathFor } from "./connection/socket-path.js";
9
10
  import { FlightServer } from "./coordinator/flight-server.js";
10
11
  import { FlightFailedError, FlightInterruptedError, failureOf, } from "./errors.js";
11
12
  import { KeyLocks } from "./key-lock/key-locks.js";
12
- /** Milliseconds between two attempts to reach the coordinator, to win its term, or to take a key's lock. */
13
+ /** Milliseconds between two tries to take a key's lock (backlog #4433). */
13
14
  const POLL_INTERVAL = 10;
14
15
  /** The low bits of a token count grants within a term; the high bits are the term's epoch (`EpochTokenSource`). */
15
16
  const SEQUENCE_BITS = 32n;
@@ -25,20 +26,22 @@ export class SingleFlight {
25
26
  #codec;
26
27
  /** The flight servers this process started; disposing closes them. */
27
28
  #servers = new AsyncDisposableStack();
28
- constructor({ directory, codec, clock }) {
29
+ constructor({ directory, codec, clock, leaseDuration, }) {
29
30
  this.#codec = codec;
30
- const socketPath = socketPathFor(directory);
31
- const election = flightElection(directory, POLL_INTERVAL, clock);
31
+ // A Unix socket file in the directory on macOS and Linux; on Windows, a named pipe named by a hash of that path.
32
+ const endpoint = new PipeEndpoint(resolve(directory, 'flight.sock'), {
33
+ prefix: 'zukhruf-single-flight',
34
+ });
35
+ const election = flightElection(directory, clock, leaseDuration);
32
36
  const locks = new KeyLocks(directory, POLL_INTERVAL, clock);
33
37
  this.#client = new FlightClient(new ConnectionSupervisor(new LocalDirectoryConnector(directory, new ElectingConnector({
34
- socketPath,
38
+ address: endpoint.address,
35
39
  election,
36
- pollInterval: POLL_INTERVAL,
37
40
  clock,
38
41
  serve: async (term) => {
39
42
  // Until serving has fully started, a failure closes the new server, so no server outlives its term.
40
43
  await using starting = new AsyncDisposableStack();
41
- starting.adopt(await FlightServer.start(socketPath, term, { locks }), (started) => started.close());
44
+ starting.adopt(await FlightServer.start(endpoint, term, { locks }), (started) => started.close());
42
45
  this.#servers.use(starting.move());
43
46
  },
44
47
  }))), {
@@ -1 +1 @@
1
- {"version":3,"file":"single-flight.js","sourceRoot":"","sources":["../src/single-flight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAa,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,4GAA4G;AAC5G,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,mHAAmH;AACnH,MAAM,aAAa,GAAG,GAAG,CAAC;AAmC1B;;;;;;GAMG;AACH,MAAM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5H,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM;oBAAE,OAAO,EAAE,KAAK,EAAE,CAAC;gBAC7D,OAAO,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YAC9D,CAAC;YACD,0FAA0F;YAC1F,IAAI,IAAI,CAAC,OAAO;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3B,IAAI,CAAC;gBACH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAgB;QACjC,IAAI,SAAS,IAAI,OAAO;YAAE,MAAM,IAAI,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/single-flight",
3
- "version": "0.8.17",
3
+ "version": "0.8.19",
4
4
  "description": "Callers of one key share the run already in flight, in one process or across the processes that use one directory, and get its outcome instead of a busy error.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,16 +40,17 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@zukhruf/async": "^0.8.17",
44
- "@zukhruf/election": "^0.8.17",
45
- "@zukhruf/fencing": "^0.8.17",
46
- "@zukhruf/fs": "^0.8.17",
47
- "@zukhruf/lease": "^0.8.17"
43
+ "@zukhruf/async": "^0.8.19",
44
+ "@zukhruf/election": "^0.8.19",
45
+ "@zukhruf/fencing": "^0.8.19",
46
+ "@zukhruf/fs": "^0.8.19",
47
+ "@zukhruf/lease": "^0.8.19",
48
+ "@zukhruf/pipes": "^0.8.19"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@sinonjs/fake-timers": "15.4.0",
51
- "@zukhruf/mutex": "^0.8.17",
52
- "@zukhruf/sqlite-open": "^0.8.17",
53
- "@zukhruf/testing": "^0.8.17"
52
+ "@zukhruf/mutex": "^0.8.19",
53
+ "@zukhruf/sqlite-open": "^0.8.19",
54
+ "@zukhruf/testing": "^0.8.19"
54
55
  }
55
56
  }
@@ -1,7 +0,0 @@
1
- /**
2
- * A Unix socket file in the directory on macOS and Linux. On Windows, a named
3
- * pipe: pipe names are global, so the name comes from the directory, and
4
- * Windows paths ignore case, so the path is lowercased first.
5
- */
6
- export declare function socketPathFor(directory: string): string;
7
- //# sourceMappingURL=socket-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"socket-path.d.ts","sourceRoot":"","sources":["../../src/connection/socket-path.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAYvD"}
@@ -1,21 +0,0 @@
1
- import { hash } from 'node:crypto';
2
- import { join, resolve } from 'node:path';
3
- /** macOS allows 104 bytes including the terminating NUL; Linux allows 108. */
4
- const SOCKET_PATH_LIMIT = 103;
5
- /**
6
- * A Unix socket file in the directory on macOS and Linux. On Windows, a named
7
- * pipe: pipe names are global, so the name comes from the directory, and
8
- * Windows paths ignore case, so the path is lowercased first.
9
- */
10
- export function socketPathFor(directory) {
11
- if (process.platform === 'win32') {
12
- const id = hash('sha256', resolve(directory).toLowerCase()).slice(0, 32);
13
- return `\\\\.\\pipe\\single-flight-${id}`;
14
- }
15
- const socketPath = join(directory, 'flight.sock');
16
- if (Buffer.byteLength(socketPath) > SOCKET_PATH_LIMIT) {
17
- throw new RangeError(`The socket path ${socketPath} exceeds ${SOCKET_PATH_LIMIT} bytes; choose a shorter directory.`);
18
- }
19
- return socketPath;
20
- }
21
- //# sourceMappingURL=socket-path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"socket-path.js","sourceRoot":"","sources":["../../src/connection/socket-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,8EAA8E;AAC9E,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzE,OAAO,8BAA8B,EAAE,EAAE,CAAC;IAC5C,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAClD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,iBAAiB,EAAE,CAAC;QACtD,MAAM,IAAI,UAAU,CAClB,mBAAmB,UAAU,YAAY,iBAAiB,qCAAqC,CAChG,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}