@zukhruf/pool 0.8.18 → 0.8.20
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 +271 -0
- package/dist/climbing.d.ts.map +1 -1
- package/dist/climbing.js +10 -2
- package/dist/climbing.js.map +1 -1
- package/dist/computer-store.d.ts +7 -0
- package/dist/computer-store.d.ts.map +1 -0
- package/dist/computer-store.js +29 -0
- package/dist/computer-store.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +20 -305
- package/dist/pool.js.map +1 -1
- package/dist/slots.d.ts +52 -0
- package/dist/slots.d.ts.map +1 -0
- package/dist/slots.js +339 -0
- package/dist/slots.js.map +1 -0
- package/dist/worker-kind.d.ts +19 -0
- package/dist/worker-kind.d.ts.map +1 -0
- package/dist/worker-kind.js +28 -0
- package/dist/worker-kind.js.map +1 -0
- package/package.json +4 -4
package/dist/slots.js
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { Backoff, Latch, delay } from '@zukhruf/async';
|
|
2
|
+
// The back-off before an eager pool starts a worker again after an early
|
|
3
|
+
// exit, as Kubernetes restarts a container in CrashLoopBackOff (tuned by
|
|
4
|
+
// KEP-4603): 1 s, doubled for each early exit in a row, up to 60 s. A worker
|
|
5
|
+
// whose warm-up fails exits early too (ADR 0010).
|
|
6
|
+
const backoff = new Backoff({
|
|
7
|
+
initial: 1_000,
|
|
8
|
+
multiplier: 2,
|
|
9
|
+
max: 60_000,
|
|
10
|
+
jitter: { kind: 'none' },
|
|
11
|
+
});
|
|
12
|
+
// A worker that ran this long ends the back-off.
|
|
13
|
+
const backoffReset = 600_000;
|
|
14
|
+
// The slots of a pool and the workers in them. The sizing decides how many
|
|
15
|
+
// slots run, the startup when their workers start, and the eviction when an
|
|
16
|
+
// idle worker closes. A job takes the lowest slot with an idle worker first.
|
|
17
|
+
// A worker that exits is replaced when a job next needs its slot, or sooner
|
|
18
|
+
// when the startup is eager and the worker was idle: at once when it ran 10
|
|
19
|
+
// minutes, after a back-off when it exited early or its warm-up failed. The
|
|
20
|
+
// disposal stops every worker. Who queues the jobs, and how many at a time,
|
|
21
|
+
// is the host's: resized tells it when the sizing changes how many slots run.
|
|
22
|
+
export class Slots {
|
|
23
|
+
#create;
|
|
24
|
+
#startup;
|
|
25
|
+
#sizing;
|
|
26
|
+
#eviction;
|
|
27
|
+
#resized;
|
|
28
|
+
#slots;
|
|
29
|
+
#lent = new Set();
|
|
30
|
+
#workers = new Set();
|
|
31
|
+
#stopped = new AbortController();
|
|
32
|
+
#started = new Latch();
|
|
33
|
+
#clock;
|
|
34
|
+
// How many slots run, and since when.
|
|
35
|
+
#current;
|
|
36
|
+
#since;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
this.#clock = options.clock;
|
|
39
|
+
this.#since = this.#clock.performance.now();
|
|
40
|
+
this.#create = options.create;
|
|
41
|
+
this.#startup = options.startup;
|
|
42
|
+
this.#sizing = options.size;
|
|
43
|
+
this.#eviction = options.eviction;
|
|
44
|
+
this.#resized = options.resized;
|
|
45
|
+
this.#current = this.#sizing.current;
|
|
46
|
+
this.#slots = Array.from({ length: this.#sizing.ceiling }, (_, index) => ({
|
|
47
|
+
index,
|
|
48
|
+
state: { kind: 'empty' },
|
|
49
|
+
early: 0,
|
|
50
|
+
}));
|
|
51
|
+
const outcomes = options.startup.eager
|
|
52
|
+
? this.#running().map((slot) => this.#spawn(slot))
|
|
53
|
+
: [];
|
|
54
|
+
Promise.all(outcomes.map((outcome) => settled(outcome))).then(() => this.#started.open({ status: 'fulfilled', value: undefined }), (reason) => this.#started.open({ status: 'rejected', reason }));
|
|
55
|
+
}
|
|
56
|
+
// Aborted when the slots are disposed.
|
|
57
|
+
get stopped() {
|
|
58
|
+
return this.#stopped.signal;
|
|
59
|
+
}
|
|
60
|
+
// Settles when the workers the startup starts with the slots are ready, and
|
|
61
|
+
// rejects when one of them fails to start.
|
|
62
|
+
async ready() {
|
|
63
|
+
const outcome = await this.#started.wait();
|
|
64
|
+
if (outcome.status === 'rejected')
|
|
65
|
+
throw outcome.reason;
|
|
66
|
+
}
|
|
67
|
+
// The stats, given how many jobs wait in the host's queue.
|
|
68
|
+
stats(queued) {
|
|
69
|
+
const stats = { starting: 0, idle: 0, lent: 0, waiting: queued };
|
|
70
|
+
for (const slot of this.#slots) {
|
|
71
|
+
const lent = this.#lent.has(slot);
|
|
72
|
+
if (slot.state.kind === 'starting') {
|
|
73
|
+
stats.starting++;
|
|
74
|
+
if (lent)
|
|
75
|
+
stats.waiting++;
|
|
76
|
+
}
|
|
77
|
+
else if (slot.state.kind === 'ready') {
|
|
78
|
+
if (lent)
|
|
79
|
+
stats.lent++;
|
|
80
|
+
else
|
|
81
|
+
stats.idle++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return stats;
|
|
85
|
+
}
|
|
86
|
+
// Lends a slot to a job, the lowest of its kind: an idle worker, else a
|
|
87
|
+
// worker that starts, else an empty slot or one whose worker ended, else a
|
|
88
|
+
// back-off. Jobs stay on the low slots, so the high ones stay idle until
|
|
89
|
+
// their eviction lets them go. This is the reason Commons Pool lends the
|
|
90
|
+
// object returned last (POOL-86) and Go's database/sql reuses the connection
|
|
91
|
+
// idle for the shortest time (sql.go:1336-1341). The host lends a slot only
|
|
92
|
+
// while fewer jobs than the slots that run have one.
|
|
93
|
+
lend() {
|
|
94
|
+
const free = this.#running().filter((slot) => !this.#lent.has(slot));
|
|
95
|
+
const slot = free.find(({ state }) => state.kind === 'ready') ??
|
|
96
|
+
free.find(({ state }) => state.kind === 'starting') ??
|
|
97
|
+
free.find(({ state }) => state.kind === 'empty' || state.kind === 'lost') ??
|
|
98
|
+
free.find(({ state }) => state.kind === 'backoff');
|
|
99
|
+
this.#lent.add(slot);
|
|
100
|
+
// A job takes the worker before its eviction lets it go.
|
|
101
|
+
if (slot.state.kind === 'ready')
|
|
102
|
+
slot.state.idle.abort();
|
|
103
|
+
return slot;
|
|
104
|
+
}
|
|
105
|
+
// The ready worker of a lent slot, started first when it has none.
|
|
106
|
+
async borrow(slot) {
|
|
107
|
+
const state = slot.state;
|
|
108
|
+
if (state.kind === 'ready')
|
|
109
|
+
return state.worker;
|
|
110
|
+
if (state.kind === 'lost') {
|
|
111
|
+
this.#enter(slot, { kind: 'empty' });
|
|
112
|
+
void this.#close(state.worker);
|
|
113
|
+
}
|
|
114
|
+
// A job does not wait out a back-off: its worker starts now, and the start
|
|
115
|
+
// ends the wait of the back-off.
|
|
116
|
+
const worker = await settled(state.kind === 'starting' ? state.outcome : this.#spawn(slot));
|
|
117
|
+
const now = slot.state;
|
|
118
|
+
if (now.kind === 'ready' && now.worker === worker)
|
|
119
|
+
return worker;
|
|
120
|
+
// The worker exited between its start and this borrow.
|
|
121
|
+
return this.borrow(slot);
|
|
122
|
+
}
|
|
123
|
+
// Kills the worker of a lent slot: no job may borrow it any more.
|
|
124
|
+
kill(slot, worker) {
|
|
125
|
+
worker.kill();
|
|
126
|
+
const state = slot.state;
|
|
127
|
+
if (state.kind === 'ready' && state.worker === worker)
|
|
128
|
+
this.#enter(slot, { kind: 'lost', worker, since: state.since });
|
|
129
|
+
}
|
|
130
|
+
// A job measures how many workers pay only if, since it started, the pool
|
|
131
|
+
// ran the same number of workers and each was ready, and another job waited
|
|
132
|
+
// when it finished.
|
|
133
|
+
record(started, waited) {
|
|
134
|
+
const steady = this.#steady();
|
|
135
|
+
this.#sizing.record({
|
|
136
|
+
started,
|
|
137
|
+
finished: this.#clock.performance.now(),
|
|
138
|
+
measurable: steady !== undefined && started >= steady && waited,
|
|
139
|
+
});
|
|
140
|
+
for (const slot of this.#slots.slice(this.#sizing.kept))
|
|
141
|
+
this.#retire(slot);
|
|
142
|
+
if (this.#sizing.current === this.#current)
|
|
143
|
+
return;
|
|
144
|
+
this.#current = this.#sizing.current;
|
|
145
|
+
this.#resized(this.#current);
|
|
146
|
+
this.#since = this.#clock.performance.now();
|
|
147
|
+
// An idle worker waits for its eviction only while the pool runs its slot.
|
|
148
|
+
for (const slot of this.#slots.slice(0, this.#sizing.kept)) {
|
|
149
|
+
const state = slot.state;
|
|
150
|
+
if (state.kind === 'ready' &&
|
|
151
|
+
!this.#lent.has(slot) &&
|
|
152
|
+
state.idle.signal.aborted === slot.index < this.#sizing.current)
|
|
153
|
+
this.#rest(slot, state.worker, state.since);
|
|
154
|
+
}
|
|
155
|
+
for (const slot of this.#running())
|
|
156
|
+
if (slot.state.kind === 'empty')
|
|
157
|
+
this.#spawn(slot);
|
|
158
|
+
}
|
|
159
|
+
// The job of a lent slot ended.
|
|
160
|
+
release(slot) {
|
|
161
|
+
this.#lent.delete(slot);
|
|
162
|
+
const state = slot.state;
|
|
163
|
+
if (slot.index >= this.#sizing.kept)
|
|
164
|
+
this.#retire(slot);
|
|
165
|
+
else if (state.kind === 'ready')
|
|
166
|
+
this.#rest(slot, state.worker, state.since);
|
|
167
|
+
else if (state.kind === 'lost')
|
|
168
|
+
this.#replace(slot, state.worker, state.since);
|
|
169
|
+
}
|
|
170
|
+
#running() {
|
|
171
|
+
return this.#slots.slice(0, this.#sizing.current);
|
|
172
|
+
}
|
|
173
|
+
// Since when every slot the pool runs has had a ready worker, if they have.
|
|
174
|
+
#steady() {
|
|
175
|
+
let since = this.#since;
|
|
176
|
+
for (const { state } of this.#running()) {
|
|
177
|
+
if (state.kind !== 'ready')
|
|
178
|
+
return undefined;
|
|
179
|
+
since = Math.max(since, state.since);
|
|
180
|
+
}
|
|
181
|
+
return since;
|
|
182
|
+
}
|
|
183
|
+
#spawn(slot) {
|
|
184
|
+
const outcome = new Latch();
|
|
185
|
+
this.#enter(slot, { kind: 'starting', outcome });
|
|
186
|
+
const turn = Promise.withResolvers();
|
|
187
|
+
this.#startup
|
|
188
|
+
.turn(turn.promise)
|
|
189
|
+
.then(async () => {
|
|
190
|
+
this.#stopped.signal.throwIfAborted();
|
|
191
|
+
const worker = this.#create();
|
|
192
|
+
this.#workers.add(worker);
|
|
193
|
+
try {
|
|
194
|
+
await worker.ready?.();
|
|
195
|
+
return worker;
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
worker.kill();
|
|
199
|
+
await this.#close(worker);
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
.then((worker) => {
|
|
204
|
+
if (slot.state.kind === 'starting' && slot.state.outcome === outcome)
|
|
205
|
+
this.#rest(slot, worker, this.#clock.performance.now());
|
|
206
|
+
outcome.open({ status: 'fulfilled', value: worker });
|
|
207
|
+
turn.resolve();
|
|
208
|
+
void worker.exited().then(() => this.#ended(slot, worker));
|
|
209
|
+
}, (reason) => {
|
|
210
|
+
if (slot.state.kind === 'starting' &&
|
|
211
|
+
slot.state.outcome === outcome) {
|
|
212
|
+
this.#enter(slot, { kind: 'empty' });
|
|
213
|
+
// A failed warm-up is an early exit, whoever started the worker,
|
|
214
|
+
// as HikariCP tries a failed create again (ADR 0010).
|
|
215
|
+
if (this.#startup.eager && !this.#stopped.signal.aborted) {
|
|
216
|
+
slot.early++;
|
|
217
|
+
this.#restart(slot);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
outcome.open({ status: 'rejected', reason });
|
|
221
|
+
turn.resolve();
|
|
222
|
+
});
|
|
223
|
+
return outcome;
|
|
224
|
+
}
|
|
225
|
+
// Every change of a slot's state comes here, so a ready worker that leaves
|
|
226
|
+
// its slot ends its idle wait, and a slot that leaves its back-off ends the
|
|
227
|
+
// wait of the back-off.
|
|
228
|
+
#enter(slot, next) {
|
|
229
|
+
const state = slot.state;
|
|
230
|
+
if (state.kind === 'ready')
|
|
231
|
+
state.idle.abort();
|
|
232
|
+
else if (state.kind === 'backoff')
|
|
233
|
+
state.wait.abort();
|
|
234
|
+
slot.state = next;
|
|
235
|
+
}
|
|
236
|
+
// A worker becomes idle in a slot. Its eviction may let it go only while
|
|
237
|
+
// no job has it and the pool runs its slot: a slot the sizing keeps but does
|
|
238
|
+
// not run has the worker the sizing tries (ADR 0002).
|
|
239
|
+
#rest(slot, worker, since) {
|
|
240
|
+
const state = {
|
|
241
|
+
kind: 'ready',
|
|
242
|
+
worker,
|
|
243
|
+
since,
|
|
244
|
+
idle: new AbortController(),
|
|
245
|
+
};
|
|
246
|
+
this.#enter(slot, state);
|
|
247
|
+
if (this.#lent.has(slot) || slot.index >= this.#sizing.current) {
|
|
248
|
+
state.idle.abort();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.#eviction.idle(AbortSignal.any([state.idle.signal, this.#stopped.signal]), () => this.#evict(slot, state), this.#clock);
|
|
252
|
+
}
|
|
253
|
+
// Closes an idle worker that its eviction let go. The slot is empty before
|
|
254
|
+
// the worker closes, so its exit starts no back-off and no replacement. A
|
|
255
|
+
// worker that ran 10 minutes ends the back-off, as at an exit.
|
|
256
|
+
#evict(slot, state) {
|
|
257
|
+
if (slot.state !== state ||
|
|
258
|
+
this.#lent.has(slot) ||
|
|
259
|
+
slot.index >= this.#sizing.current ||
|
|
260
|
+
this.#stopped.signal.aborted)
|
|
261
|
+
return;
|
|
262
|
+
if (this.#clock.performance.now() - state.since >= backoffReset)
|
|
263
|
+
slot.early = 0;
|
|
264
|
+
this.#retire(slot);
|
|
265
|
+
}
|
|
266
|
+
#ended(slot, worker) {
|
|
267
|
+
const state = slot.state;
|
|
268
|
+
if ((state.kind !== 'ready' && state.kind !== 'lost') ||
|
|
269
|
+
state.worker !== worker)
|
|
270
|
+
return;
|
|
271
|
+
this.#enter(slot, { kind: 'lost', worker, since: state.since });
|
|
272
|
+
if (!this.#lent.has(slot))
|
|
273
|
+
this.#replace(slot, worker, state.since);
|
|
274
|
+
}
|
|
275
|
+
// An eager pool closes the worker of a lost slot that no job has, and
|
|
276
|
+
// starts the next one.
|
|
277
|
+
#replace(slot, worker, since) {
|
|
278
|
+
if (this.#stopped.signal.aborted || !this.#startup.eager)
|
|
279
|
+
return;
|
|
280
|
+
this.#enter(slot, { kind: 'empty' });
|
|
281
|
+
void this.#close(worker);
|
|
282
|
+
slot.early =
|
|
283
|
+
this.#clock.performance.now() - since < backoffReset ? slot.early + 1 : 0;
|
|
284
|
+
this.#restart(slot);
|
|
285
|
+
}
|
|
286
|
+
// Starts the next worker of an empty slot that the pool runs: at once when
|
|
287
|
+
// no early exit came before, else after the back-off. A job that takes the
|
|
288
|
+
// slot, the sizing that stops keeping it, or the disposal ends the wait.
|
|
289
|
+
#restart(slot) {
|
|
290
|
+
if (slot.index >= this.#sizing.current)
|
|
291
|
+
return;
|
|
292
|
+
if (slot.early === 0) {
|
|
293
|
+
this.#spawn(slot);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const state = { kind: 'backoff', wait: new AbortController() };
|
|
297
|
+
this.#enter(slot, state);
|
|
298
|
+
delay(backoff.duration(slot.early - 1), {
|
|
299
|
+
clock: this.#clock,
|
|
300
|
+
signal: AbortSignal.any([state.wait.signal, this.#stopped.signal]),
|
|
301
|
+
}).then(() => {
|
|
302
|
+
if (slot.state !== state)
|
|
303
|
+
return;
|
|
304
|
+
this.#enter(slot, { kind: 'empty' });
|
|
305
|
+
if (slot.index < this.#sizing.current)
|
|
306
|
+
this.#spawn(slot);
|
|
307
|
+
}, () => undefined);
|
|
308
|
+
}
|
|
309
|
+
// Closes the worker of a slot the pool no longer keeps, once its job ends.
|
|
310
|
+
#retire(slot) {
|
|
311
|
+
if (this.#lent.has(slot))
|
|
312
|
+
return;
|
|
313
|
+
const state = slot.state;
|
|
314
|
+
this.#enter(slot, { kind: 'empty' });
|
|
315
|
+
if (state.kind === 'ready' || state.kind === 'lost')
|
|
316
|
+
void this.#close(state.worker);
|
|
317
|
+
else if (state.kind === 'starting')
|
|
318
|
+
void settled(state.outcome).then((worker) => this.#close(worker), () => undefined);
|
|
319
|
+
}
|
|
320
|
+
async #close(worker) {
|
|
321
|
+
await worker.close();
|
|
322
|
+
this.#workers.delete(worker);
|
|
323
|
+
}
|
|
324
|
+
async [Symbol.asyncDispose]() {
|
|
325
|
+
// The stop also ends the wait of each back-off.
|
|
326
|
+
this.#stopped.abort();
|
|
327
|
+
for (const worker of this.#workers)
|
|
328
|
+
worker.kill();
|
|
329
|
+
await Promise.all([...this.#workers].map((worker) => worker.close()));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// The worker a creation gave, or its failure.
|
|
333
|
+
async function settled(outcome) {
|
|
334
|
+
const result = await outcome.wait();
|
|
335
|
+
if (result.status === 'rejected')
|
|
336
|
+
throw result.reason;
|
|
337
|
+
return result.value;
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.js","sourceRoot":"","sources":["../src/slots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAc,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAQnE,yEAAyE;AACzE,yEAAyE;AACzE,6EAA6E;AAC7E,kDAAkD;AAClD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;IAC1B,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,CAAC;IACb,GAAG,EAAE,MAAM;IACX,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;CACzB,CAAC,CAAC;AAEH,iDAAiD;AACjD,MAAM,YAAY,GAAG,OAAO,CAAC;AA+B7B,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,MAAM,OAAO,KAAK;IACP,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,OAAO,CAAS;IAChB,SAAS,CAAW;IACpB,QAAQ,CAA4B;IACpC,MAAM,CAAY;IAClB,KAAK,GAAG,IAAI,GAAG,EAAW,CAAC;IAC3B,QAAQ,GAAG,IAAI,GAAG,EAAK,CAAC;I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,SAAS,CAChB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAS;QACpB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,gDAAgD;QAChD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;CACF;AAED,8CAA8C;AAC9C,KAAK,UAAU,OAAO,CAAI,OAAuC;IAC/D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU;QAAE,MAAM,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The name, the revision and the job rules of a pool, with the types of its input and its output. */
|
|
2
|
+
export declare class WorkerKind<Input, Output> {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly revision: number;
|
|
5
|
+
readonly policy: 'standard' | 'exclusive';
|
|
6
|
+
readonly retryLimit: number;
|
|
7
|
+
readonly expireInSeconds: number;
|
|
8
|
+
/** The queue of this revision in the store, `<name>.r<revision>` (ADR 0022). */
|
|
9
|
+
readonly queue: string;
|
|
10
|
+
private readonly types;
|
|
11
|
+
constructor(options: {
|
|
12
|
+
name: string;
|
|
13
|
+
revision: number;
|
|
14
|
+
policy: 'standard' | 'exclusive';
|
|
15
|
+
retryLimit: number;
|
|
16
|
+
expireInSeconds: number;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=worker-kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-kind.d.ts","sourceRoot":"","sources":["../src/worker-kind.ts"],"names":[],"mappings":"AAOA,sGAAsG;AACtG,qBAAa,UAAU,CAAC,KAAK,EAAE,MAAM;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAGvB,iBAAyB,KAAK,CAA2B;gBAE7C,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;QACjC,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;KACzB;CAaF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Postgres and @zukhruf/sqlite-notify take a channel name shorter than
|
|
2
|
+
// NAMEDATALEN (64) bytes.
|
|
3
|
+
const NAMEDATALEN = 64;
|
|
4
|
+
// The longer of the two channels of a pool (ADR 0018), "<name>.new-job" and
|
|
5
|
+
// "<name>.output", so a name that fits it fits both.
|
|
6
|
+
const LONGER_CHANNEL = 'new-job';
|
|
7
|
+
/** The name, the revision and the job rules of a pool, with the types of its input and its output. */
|
|
8
|
+
export class WorkerKind {
|
|
9
|
+
name;
|
|
10
|
+
revision;
|
|
11
|
+
policy;
|
|
12
|
+
retryLimit;
|
|
13
|
+
expireInSeconds;
|
|
14
|
+
/** The queue of this revision in the store, `<name>.r<revision>` (ADR 0022). */
|
|
15
|
+
queue;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
const channel = `${options.name}.${LONGER_CHANNEL}`;
|
|
18
|
+
if (Buffer.byteLength(channel) >= NAMEDATALEN)
|
|
19
|
+
throw new RangeError(`worker kind name too long: its channel "${channel}" must be shorter than ${NAMEDATALEN} bytes`);
|
|
20
|
+
this.name = options.name;
|
|
21
|
+
this.revision = options.revision;
|
|
22
|
+
this.policy = options.policy;
|
|
23
|
+
this.retryLimit = options.retryLimit;
|
|
24
|
+
this.expireInSeconds = options.expireInSeconds;
|
|
25
|
+
this.queue = `${options.name}.r${options.revision}`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=worker-kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-kind.js","sourceRoot":"","sources":["../src/worker-kind.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,0BAA0B;AAC1B,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,4EAA4E;AAC5E,qDAAqD;AACrD,MAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,sGAAsG;AACtG,MAAM,OAAO,UAAU;IACZ,IAAI,CAAS;IACb,QAAQ,CAAS;IACjB,MAAM,CAA2B;IACjC,UAAU,CAAS;IACnB,eAAe,CAAS;IACjC,gFAAgF;IACvE,KAAK,CAAS;IAKvB,YAAY,OAMX;QACC,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,IAAI,IAAI,cAAc,EAAE,CAAC;QACpD,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,WAAW;YAC3C,MAAM,IAAI,UAAU,CAClB,2CAA2C,OAAO,0BAA0B,WAAW,QAAQ,CAChG,CAAC;QACJ,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,KAAK,GAAG,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/pool",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.8.20",
|
|
4
|
+
"description": "Lends long-lived workers, such as native helper processes, to one job at a time: startups decide when workers start, sizings decide how many run, evictions decide when an idle worker closes, and a worker that exits is replaced.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@zukhruf/async": "^0.8.
|
|
44
|
+
"@zukhruf/async": "^0.8.20",
|
|
45
45
|
"p-queue": "10.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@sinonjs/fake-timers": "15.4.0",
|
|
49
|
-
"@zukhruf/testing": "^0.8.
|
|
49
|
+
"@zukhruf/testing": "^0.8.20"
|
|
50
50
|
}
|
|
51
51
|
}
|