@zukhruf/sqlite-notify 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +286 -2
- package/dist/columns.d.ts +10 -0
- package/dist/columns.d.ts.map +1 -0
- package/dist/columns.js +26 -0
- package/dist/columns.js.map +1 -0
- package/dist/disposed-error.d.ts +5 -0
- package/dist/disposed-error.d.ts.map +1 -0
- package/dist/disposed-error.js +8 -0
- package/dist/disposed-error.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +3 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +16 -0
- package/dist/limits.js.map +1 -0
- package/dist/listening.d.ts +46 -0
- package/dist/listening.d.ts.map +1 -0
- package/dist/listening.js +259 -0
- package/dist/listening.js.map +1 -0
- package/dist/notifications.d.ts +43 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +240 -0
- package/dist/notifications.js.map +1 -0
- package/dist/queue-full-error.d.ts +7 -0
- package/dist/queue-full-error.d.ts.map +1 -0
- package/dist/queue-full-error.js +10 -0
- package/dist/queue-full-error.js.map +1 -0
- package/dist/release.d.ts +8 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +27 -0
- package/dist/release.js.map +1 -0
- package/dist/removal-check.d.ts +15 -0
- package/dist/removal-check.d.ts.map +1 -0
- package/dist/removal-check.js +45 -0
- package/dist/removal-check.js.map +1 -0
- package/dist/schema.d.ts +4 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +40 -0
- package/dist/schema.js.map +1 -0
- package/dist/steps.d.ts +6 -0
- package/dist/steps.d.ts.map +1 -0
- package/dist/steps.js +23 -0
- package/dist/steps.js.map +1 -0
- package/dist/tables.d.ts +6 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +57 -0
- package/dist/tables.js.map +1 -0
- package/dist/wakes.d.ts +24 -0
- package/dist/wakes.d.ts.map +1 -0
- package/dist/wakes.js +176 -0
- package/dist/wakes.js.map +1 -0
- package/package.json +52 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import type { Wakes } from './wakes.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Tells whether a caller's transaction committed the removal of the rows of
|
|
5
|
+
* dead listeners. On the microtask after the notify, the caller's synchronous
|
|
6
|
+
* transaction has ended (ADR 0004); a read then finds the rows gone after a
|
|
7
|
+
* commit, and still there after a rollback (ADR 0010).
|
|
8
|
+
*/
|
|
9
|
+
export declare class RemovalCheck {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(database: DatabaseSync, wakes: Wakes, fail: (error: unknown) => void);
|
|
12
|
+
/** After a notify in a caller's transaction that removed the rows of the dead listeners. */
|
|
13
|
+
removedInCallersTransaction(dead: ReadonlyMap<string, string>): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=removal-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removal-check.d.ts","sourceRoot":"","sources":["../src/removal-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;GAKG;AACH,qBAAa,YAAY;;gBAUrB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAUhC,4FAA4F;IAC5F,2BAA2B,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;CAoBrE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells whether a caller's transaction committed the removal of the rows of
|
|
3
|
+
* dead listeners. On the microtask after the notify, the caller's synchronous
|
|
4
|
+
* transaction has ended (ADR 0004); a read then finds the rows gone after a
|
|
5
|
+
* commit, and still there after a rollback (ADR 0010).
|
|
6
|
+
*/
|
|
7
|
+
export class RemovalCheck {
|
|
8
|
+
#database;
|
|
9
|
+
#wakes;
|
|
10
|
+
#fail;
|
|
11
|
+
#listener;
|
|
12
|
+
// The dead listeners whose rows the notifies of this turn removed; a
|
|
13
|
+
// microtask is queued while the map is not empty.
|
|
14
|
+
#pending = new Map();
|
|
15
|
+
constructor(database, wakes, fail) {
|
|
16
|
+
this.#database = database;
|
|
17
|
+
this.#wakes = wakes;
|
|
18
|
+
this.#fail = fail;
|
|
19
|
+
this.#listener = database.prepare('SELECT 1 FROM zukhruf_notify_listener WHERE id = ?');
|
|
20
|
+
}
|
|
21
|
+
/** After a notify in a caller's transaction that removed the rows of the dead listeners. */
|
|
22
|
+
removedInCallersTransaction(dead) {
|
|
23
|
+
if (dead.size === 0)
|
|
24
|
+
return;
|
|
25
|
+
if (this.#pending.size === 0)
|
|
26
|
+
queueMicrotask(() => this.#check());
|
|
27
|
+
for (const [id, address] of dead)
|
|
28
|
+
this.#pending.set(id, address);
|
|
29
|
+
}
|
|
30
|
+
// A transaction still open belongs to a caller that keeps it across an
|
|
31
|
+
// await: its end is unknown, and the next notify removes the rows again.
|
|
32
|
+
#check() {
|
|
33
|
+
const pending = [...this.#pending];
|
|
34
|
+
this.#pending.clear();
|
|
35
|
+
if (this.#database.isTransaction)
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
this.#wakes.removed(new Map(pending.filter(([id]) => this.#listener.get(id) === undefined)));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.#fail(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=removal-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removal-check.js","sourceR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CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,CAAC,CACxE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;CACF"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,eAAO,MAAM,YAAY,aAkCxB,CAAC;AAIF,eAAO,MAAM,UAAU,uFAAuF,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Declaration } from '@zukhruf/sqlite-drift';
|
|
2
|
+
// The tables of the notification queue, the listeners and their channels. The
|
|
3
|
+
// constructor makes a file store them as declared, and keeps the rows of each
|
|
4
|
+
// table that a later release rebuilds (README, "The tables").
|
|
5
|
+
export const notifySchema = new Declaration([
|
|
6
|
+
// AUTOINCREMENT: a plain INTEGER PRIMARY KEY gives the ids of trimmed rows
|
|
7
|
+
// again, and a listener whose last id is higher never reads the new rows
|
|
8
|
+
// (research 20b T2).
|
|
9
|
+
`CREATE TABLE zukhruf_notify_queue (
|
|
10
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
11
|
+
channel TEXT NOT NULL,
|
|
12
|
+
payload TEXT NOT NULL,
|
|
13
|
+
process_id INTEGER NOT NULL
|
|
14
|
+
) STRICT`,
|
|
15
|
+
`CREATE TABLE zukhruf_notify_listener (
|
|
16
|
+
id TEXT PRIMARY KEY,
|
|
17
|
+
address TEXT NOT NULL UNIQUE,
|
|
18
|
+
position INTEGER NOT NULL,
|
|
19
|
+
process_id INTEGER NOT NULL
|
|
20
|
+
) STRICT`,
|
|
21
|
+
`CREATE INDEX zukhruf_notify_listener_position ON zukhruf_notify_listener (position)`,
|
|
22
|
+
// No foreign key: a caller's connection can have foreign_keys off, so the
|
|
23
|
+
// package removes the channel rows of a listener with its listener row.
|
|
24
|
+
`CREATE TABLE zukhruf_notify_channel (
|
|
25
|
+
channel TEXT NOT NULL,
|
|
26
|
+
listener TEXT NOT NULL,
|
|
27
|
+
PRIMARY KEY (channel, listener)
|
|
28
|
+
) STRICT, WITHOUT ROWID`,
|
|
29
|
+
// One row: the release of this package that last applied the declaration
|
|
30
|
+
// (docs/adr/0009). Not PRAGMA user_version: a file has one, and the tables
|
|
31
|
+
// of another package can share the file.
|
|
32
|
+
`CREATE TABLE zukhruf_notify_version (
|
|
33
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
34
|
+
version TEXT NOT NULL
|
|
35
|
+
) STRICT`,
|
|
36
|
+
], { rows: 'keep' });
|
|
37
|
+
// The highest id ever given. It is the seq of sqlite_sequence, so it stays
|
|
38
|
+
// right when the trim removed every row.
|
|
39
|
+
export const HIGHEST_ID = `coalesce((SELECT seq FROM sqlite_sequence WHERE name = 'zukhruf_notify_queue'), 0)`;
|
|
40
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,8EAA8E;AAC9E,8EAA8E;AAC9E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,WAAW,CACzC;IACE,2EAA2E;IAC3E,yEAAyE;IACzE,qBAAqB;IACrB;;;;;WAKO;IACP;;;;;WAKO;IACP,qFAAqF;IACrF,0EAA0E;IAC1E,wEAAwE;IACxE;;;;0BAIsB;IACtB,yEAAyE;IACzE,2EAA2E;IAC3E,yCAAyC;IACzC;;;WAGO;CACR,EACD,EAAE,IAAI,EAAE,MAAM,EAAE,CACjB,CAAC;AAEF,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,CAAC,MAAM,UAAU,GAAG,oFAAoF,CAAC"}
|
package/dist/steps.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAOA,oEAAoE;AACpE,qBAAa,KAAK;;IAIV,GAAG,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAepD"}
|
package/dist/steps.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Latch } from '@zukhruf/async';
|
|
2
|
+
/** Runs async work one after another, in the order of the calls. */
|
|
3
|
+
export class Steps {
|
|
4
|
+
// The step at the head runs; the queue is empty when nothing runs.
|
|
5
|
+
#queue = [];
|
|
6
|
+
async run(work) {
|
|
7
|
+
const step = { work, outcome: new Latch() };
|
|
8
|
+
this.#queue.push(step);
|
|
9
|
+
if (this.#queue.length === 1)
|
|
10
|
+
void this.#drain();
|
|
11
|
+
const outcome = await step.outcome.wait();
|
|
12
|
+
if (outcome.status === 'rejected')
|
|
13
|
+
throw outcome.reason;
|
|
14
|
+
}
|
|
15
|
+
async #drain() {
|
|
16
|
+
for (let step = this.#queue[0]; step; step = this.#queue[0]) {
|
|
17
|
+
const [outcome] = await Promise.allSettled([Promise.try(step.work)]);
|
|
18
|
+
this.#queue.shift();
|
|
19
|
+
step.outcome.open(outcome);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAOvC,oEAAoE;AACpE,MAAM,OAAO,KAAK;IAChB,mEAAmE;IAC1D,MAAM,GAAW,EAAE,CAAC;IAE7B,KAAK,CAAC,GAAG,CAAC,IAAyB;QACjC,MAAM,IAAI,GAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU;YAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,MAAM;QACV,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
|
package/dist/tables.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../src/tables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWhD,qBAAa,MAAM;;IACjB,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;CA0D7C"}
|
package/dist/tables.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { transaction } from '@zukhruf/sqlite-transaction';
|
|
2
|
+
import { Release } from "./release.js";
|
|
3
|
+
import { notifySchema } from "./schema.js";
|
|
4
|
+
// The tables of a file: a file that a later release made stays as it is, and
|
|
5
|
+
// any other file gets this release's tables with their rows kept (docs/adr/
|
|
6
|
+
// 0009). A copy of Contractor of @zukhruf/sqlite-queue (docs/copied-from-
|
|
7
|
+
// sqlite-queue.md).
|
|
8
|
+
export class Tables {
|
|
9
|
+
static install(database) {
|
|
10
|
+
// A WAL reader does not wait for a writer, so a file that needs no change
|
|
11
|
+
// gets its Notifications next to the write of another program.
|
|
12
|
+
if (Tables.#settled(database))
|
|
13
|
+
return;
|
|
14
|
+
// The read of the release must share the write lock with the apply.
|
|
15
|
+
transaction(database, () => {
|
|
16
|
+
const installed = Tables.#installed(database);
|
|
17
|
+
if (installed?.isAfter(Release.current))
|
|
18
|
+
return;
|
|
19
|
+
notifySchema.apply(database);
|
|
20
|
+
database
|
|
21
|
+
.prepare(`INSERT INTO zukhruf_notify_version (singleton, version) VALUES (1, ?)
|
|
22
|
+
ON CONFLICT (singleton) DO UPDATE SET version = excluded.version`)
|
|
23
|
+
.run(Release.current.version);
|
|
24
|
+
}, { mode: 'immediate' });
|
|
25
|
+
}
|
|
26
|
+
// The file records a later release, or this release and fits the
|
|
27
|
+
// declaration. The two reads share one snapshot. The locked transaction
|
|
28
|
+
// reads both again, so a program that changes the file after this read
|
|
29
|
+
// cannot make install() act on it.
|
|
30
|
+
static #settled(database) {
|
|
31
|
+
return transaction(database, () => {
|
|
32
|
+
const installed = Tables.#installed(database);
|
|
33
|
+
if (installed === undefined)
|
|
34
|
+
return false;
|
|
35
|
+
if (installed.isAfter(Release.current))
|
|
36
|
+
return true;
|
|
37
|
+
return (installed.version === Release.current.version &&
|
|
38
|
+
notifySchema.drift(database) === 'fits');
|
|
39
|
+
}, { mode: 'deferred' });
|
|
40
|
+
}
|
|
41
|
+
// The release that the file records. A new file, or a file that a release
|
|
42
|
+
// before the version record made, records none.
|
|
43
|
+
static #installed(database) {
|
|
44
|
+
const recorded = database
|
|
45
|
+
.prepare(`SELECT 1 FROM pragma_table_info('zukhruf_notify_version') WHERE name = 'version'`)
|
|
46
|
+
.get();
|
|
47
|
+
if (recorded === undefined)
|
|
48
|
+
return undefined;
|
|
49
|
+
const row = database
|
|
50
|
+
.prepare('SELECT version FROM zukhruf_notify_version')
|
|
51
|
+
.get();
|
|
52
|
+
return typeof row?.version === 'string'
|
|
53
|
+
? new Release(row.version)
|
|
54
|
+
: undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../src/tables.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,oBAAoB;AACpB,MAAM,OAAO,MAAM;IACjB,MAAM,CAAC,OAAO,CAAC,QAAsB;QACnC,0EAA0E;QAC1E,+DAA+D;QAC/D,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO;QACtC,oEAAoE;QACpE,WAAW,CACT,QAAQ,EACR,GAAG,EAAE;YACH,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE,OAAO;YAChD,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC7B,QAAQ;iBACL,OAAO,CACN;6EACiE,CAClE;iBACA,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC,EACD,EAAE,IAAI,EAAE,WAAW,EAAE,CACtB,CAAC;IACJ,CAAC;IAED,iEAAiE;IACjE,wEAAwE;IACxE,uEAAuE;IACvE,mCAAmC;IACnC,MAAM,CAAC,QAAQ,CAAC,QAAsB;QACpC,OAAO,WAAW,CAChB,QAAQ,EACR,GAAG,EAAE;YACH,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,SAAS,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;YAC1C,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE,OAAO,IAAI,CAAC;YACpD,OAAO,CACL,SAAS,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,OAAO;gBAC7C,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,MAAM,CACxC,CAAC;QACJ,CAAC,EACD,EAAE,IAAI,EAAE,UAAU,EAAE,CACrB,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,gDAAgD;IAChD,MAAM,CAAC,UAAU,CAAC,QAAsB;QACtC,MAAM,QAAQ,GAAG,QAAQ;aACtB,OAAO,CACN,kFAAkF,CACnF;aACA,GAAG,EAAE,CAAC;QACT,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC7C,MAAM,GAAG,GAAG,QAAQ;aACjB,OAAO,CAAC,4CAA4C,CAAC;aACrD,GAAG,EAAE,CAAC;QACT,OAAO,OAAO,GAAG,EAAE,OAAO,KAAK,QAAQ;YACrC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;YAC1B,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;CACF"}
|
package/dist/wakes.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A listener as a sender reads it from its row. */
|
|
2
|
+
export interface Addressed {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly address: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The sender's side: one connection to each listener it woke, the wakes that
|
|
8
|
+
* are due on the next microtask, and the listeners it found dead (ADR 0003,
|
|
9
|
+
* ADR 0004).
|
|
10
|
+
*/
|
|
11
|
+
export declare class Wakes {
|
|
12
|
+
#private;
|
|
13
|
+
/** `wakeOwn` wakes the listener of the sending instance with no socket, and tells whether the id was its own. */
|
|
14
|
+
constructor(wakeOwn: (id: string) => boolean, fail: (error: unknown) => void);
|
|
15
|
+
/** The listeners found dead, whose rows each transaction removes until `removed` forgets them. */
|
|
16
|
+
dead(): ReadonlyMap<string, string>;
|
|
17
|
+
/** After a transaction that returned: each listener read gets one wake on the next microtask. */
|
|
18
|
+
sent(listeners: readonly Addressed[]): void;
|
|
19
|
+
/** After a commit that removed their rows: the dead listeners are forgotten and lose their socket files. */
|
|
20
|
+
removed(dead: ReadonlyMap<string, string>): void;
|
|
21
|
+
/** Writes the wakes that are due, ends the connections, and waits for the removals of socket files. */
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=wakes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wakes.d.ts","sourceRoot":"","sources":["../src/wakes.ts"],"names":[],"mappings":"AAMA,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AASD;;;;GAIG;AACH,qBAAa,KAAK;;IAUhB,iHAAiH;gBAE/G,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,EAChC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAMhC,kGAAkG;IAClG,IAAI,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAInC,iGAAiG;IACjG,IAAI,CAAC,SAAS,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI;IAM3C,4GAA4G;IAC5G,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOhD,uGAAuG;IACjG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CA4C7B"}
|
package/dist/wakes.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { rm } from 'node:fs/promises';
|
|
2
|
+
import { Latch } from '@zukhruf/async';
|
|
3
|
+
import { PipeAddress } from '@zukhruf/pipes';
|
|
4
|
+
// The wake: one byte with no content (ADR 0002).
|
|
5
|
+
const WAKE = Buffer.of(0);
|
|
6
|
+
// The connect errors that mean nobody serves the address any more: a file
|
|
7
|
+
// that a killed listener left (ECONNREFUSED), or no file (ENOENT).
|
|
8
|
+
const DEAD_CODES = new Set(['ECONNREFUSED', 'ENOENT']);
|
|
9
|
+
/**
|
|
10
|
+
* The sender's side: one connection to each listener it woke, the wakes that
|
|
11
|
+
* are due on the next microtask, and the listeners it found dead (ADR 0003,
|
|
12
|
+
* ADR 0004).
|
|
13
|
+
*/
|
|
14
|
+
export class Wakes {
|
|
15
|
+
#connections = new Map();
|
|
16
|
+
#dead = new Map();
|
|
17
|
+
// The wakes of the transactions of this turn; a microtask is queued while
|
|
18
|
+
// the map is not empty.
|
|
19
|
+
#due = new Map();
|
|
20
|
+
#removals = new Set();
|
|
21
|
+
#wakeOwn;
|
|
22
|
+
#fail;
|
|
23
|
+
/** `wakeOwn` wakes the listener of the sending instance with no socket, and tells whether the id was its own. */
|
|
24
|
+
constructor(wakeOwn, fail) {
|
|
25
|
+
this.#wakeOwn = wakeOwn;
|
|
26
|
+
this.#fail = fail;
|
|
27
|
+
}
|
|
28
|
+
/** The listeners found dead, whose rows each transaction removes until `removed` forgets them. */
|
|
29
|
+
dead() {
|
|
30
|
+
return new Map(this.#dead);
|
|
31
|
+
}
|
|
32
|
+
/** After a transaction that returned: each listener read gets one wake on the next microtask. */
|
|
33
|
+
sent(listeners) {
|
|
34
|
+
if (listeners.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
if (this.#due.size === 0)
|
|
37
|
+
queueMicrotask(() => this.#flush());
|
|
38
|
+
for (const { id, address } of listeners)
|
|
39
|
+
this.#due.set(id, address);
|
|
40
|
+
}
|
|
41
|
+
/** After a commit that removed their rows: the dead listeners are forgotten and lose their socket files. */
|
|
42
|
+
removed(dead) {
|
|
43
|
+
for (const [id, address] of dead) {
|
|
44
|
+
this.#dead.delete(id);
|
|
45
|
+
this.#removeFile(address);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Writes the wakes that are due, ends the connections, and waits for the removals of socket files. */
|
|
49
|
+
async close() {
|
|
50
|
+
this.#flush();
|
|
51
|
+
const connections = [...this.#connections.values()];
|
|
52
|
+
this.#connections.clear();
|
|
53
|
+
await Promise.all(connections.map((connection) => connection.end()));
|
|
54
|
+
await Promise.all([...this.#removals].map((removal) => removal.wait()));
|
|
55
|
+
}
|
|
56
|
+
#flush() {
|
|
57
|
+
for (const [id, address] of this.#due) {
|
|
58
|
+
if (this.#dead.has(id) || this.#wakeOwn(id))
|
|
59
|
+
continue;
|
|
60
|
+
let connection = this.#connections.get(id);
|
|
61
|
+
if (connection === undefined) {
|
|
62
|
+
connection = new Connection(address, {
|
|
63
|
+
dead: () => {
|
|
64
|
+
this.#connections.delete(id);
|
|
65
|
+
this.#dead.set(id, address);
|
|
66
|
+
},
|
|
67
|
+
lost: (error) => {
|
|
68
|
+
this.#connections.delete(id);
|
|
69
|
+
this.#fail(error);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
this.#connections.set(id, connection);
|
|
73
|
+
}
|
|
74
|
+
connection.wake();
|
|
75
|
+
}
|
|
76
|
+
this.#due.clear();
|
|
77
|
+
}
|
|
78
|
+
// A killed listener's socket file stays (research 20a P1); the sender that
|
|
79
|
+
// removes its row removes the file (research 20e R4, variant B). Windows
|
|
80
|
+
// removes a pipe when its program exits.
|
|
81
|
+
#removeFile(address) {
|
|
82
|
+
if (process.platform === 'win32')
|
|
83
|
+
return;
|
|
84
|
+
const removal = new Latch();
|
|
85
|
+
this.#removals.add(removal);
|
|
86
|
+
void rm(address, { force: true })
|
|
87
|
+
.catch(this.#fail)
|
|
88
|
+
.finally(() => {
|
|
89
|
+
this.#removals.delete(removal);
|
|
90
|
+
removal.open();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** One connection to one listener, with at most one wake in flight and at most one owed (research 20e R3). */
|
|
95
|
+
class Connection {
|
|
96
|
+
#connected = new Latch();
|
|
97
|
+
#state = { kind: 'connecting', owed: true, ending: false };
|
|
98
|
+
constructor(address, events) {
|
|
99
|
+
void new PipeAddress(address)
|
|
100
|
+
.connect()
|
|
101
|
+
.then((socket) => this.#opened(socket, events), (error) => {
|
|
102
|
+
if (this.#state.kind === 'ended')
|
|
103
|
+
return;
|
|
104
|
+
this.#state = { kind: 'ended' };
|
|
105
|
+
if (DEAD_CODES.has(String(Reflect.get(Object(error), 'code'))))
|
|
106
|
+
events.dead();
|
|
107
|
+
else
|
|
108
|
+
events.lost(error);
|
|
109
|
+
})
|
|
110
|
+
.finally(() => this.#connected.open());
|
|
111
|
+
}
|
|
112
|
+
wake() {
|
|
113
|
+
const state = this.#state;
|
|
114
|
+
if (state.kind === 'ended')
|
|
115
|
+
return;
|
|
116
|
+
if (state.kind === 'connecting' || state.inFlight) {
|
|
117
|
+
state.owed = true;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (state.socket.destroyed)
|
|
121
|
+
return;
|
|
122
|
+
state.inFlight = true;
|
|
123
|
+
state.socket.write(WAKE, () => this.#flushed());
|
|
124
|
+
}
|
|
125
|
+
/** Ends the connection after the wakes that the system took; drops a wake that a hung listener does not read. */
|
|
126
|
+
async end() {
|
|
127
|
+
if (this.#state.kind === 'connecting') {
|
|
128
|
+
// The owed wake goes out when the connect succeeds, before the end.
|
|
129
|
+
this.#state.ending = true;
|
|
130
|
+
await this.#connected.wait();
|
|
131
|
+
}
|
|
132
|
+
const state = this.#state;
|
|
133
|
+
this.#state = { kind: 'ended' };
|
|
134
|
+
if (state.kind !== 'open' || state.socket.closed)
|
|
135
|
+
return;
|
|
136
|
+
const { socket } = state;
|
|
137
|
+
const closed = new Promise((resolve) => socket.once('close', resolve));
|
|
138
|
+
if (socket.writableLength > 0)
|
|
139
|
+
socket.destroy();
|
|
140
|
+
else
|
|
141
|
+
socket.end(() => socket.destroy());
|
|
142
|
+
await closed;
|
|
143
|
+
}
|
|
144
|
+
#opened(socket, events) {
|
|
145
|
+
if (this.#state.kind !== 'connecting') {
|
|
146
|
+
socket.destroy();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// The sender's connections do not keep its program alive.
|
|
150
|
+
socket.unref();
|
|
151
|
+
// Reading lets the listener's close arrive; it sends nothing else.
|
|
152
|
+
socket.resume();
|
|
153
|
+
socket.on('error', () => { });
|
|
154
|
+
socket.on('close', () => {
|
|
155
|
+
if (this.#state.kind === 'ended')
|
|
156
|
+
return;
|
|
157
|
+
this.#state = { kind: 'ended' };
|
|
158
|
+
events.dead();
|
|
159
|
+
});
|
|
160
|
+
const { owed } = this.#state;
|
|
161
|
+
this.#state = { kind: 'open', socket, inFlight: false, owed: false };
|
|
162
|
+
if (owed)
|
|
163
|
+
this.wake();
|
|
164
|
+
}
|
|
165
|
+
#flushed() {
|
|
166
|
+
const state = this.#state;
|
|
167
|
+
if (state.kind !== 'open')
|
|
168
|
+
return;
|
|
169
|
+
state.inFlight = false;
|
|
170
|
+
if (!state.owed)
|
|
171
|
+
return;
|
|
172
|
+
state.owed = false;
|
|
173
|
+
this.wake();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=wakes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wakes.js","sourceRoot":"","sources":["../src/wakes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,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C;QAC7B,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACrE,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAED,QAAQ;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO;QAClC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI;YAAE,OAAO;QACxB,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/sqlite-notify",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.8.19",
|
|
4
|
+
"description": "Postgres's LISTEN and NOTIFY for one SQLite file: a notification is a row written in the sender's transaction, and each listening program of the computer gets it after the commit, woken over its own Unix socket or named pipe.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/JanuaryLabs/zukhruf",
|
|
9
|
+
"directory": "packages/sqlite/notify"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/JanuaryLabs/zukhruf/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/JanuaryLabs/zukhruf/tree/main/packages/sqlite/notify#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"sqlite",
|
|
17
|
+
"node-sqlite",
|
|
18
|
+
"listen",
|
|
19
|
+
"notify",
|
|
20
|
+
"pubsub",
|
|
21
|
+
"ipc",
|
|
22
|
+
"unix-socket"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
".": {
|
|
28
|
+
"@zukhruf/source": "./src/index.ts",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"!dist/spec/**",
|
|
37
|
+
"!**/*.tsbuildinfo",
|
|
38
|
+
"!**/*.test.*"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@zukhruf/async": "^0.8.19",
|
|
45
|
+
"@zukhruf/pipes": "^0.8.19",
|
|
46
|
+
"@zukhruf/sqlite-drift": "^0.8.19",
|
|
47
|
+
"@zukhruf/sqlite-open": "^0.8.19",
|
|
48
|
+
"@zukhruf/sqlite-transaction": "^0.8.19"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@sinonjs/fake-timers": "15.4.0",
|
|
52
|
+
"@zukhruf/testing": "^0.8.19"
|
|
53
|
+
}
|
|
54
|
+
}
|