@substrat-run/adapter-cloudflare 0.214.0 → 0.216.0
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/dist/connection-sweep-do.d.ts +83 -0
- package/dist/connection-sweep-do.d.ts.map +1 -0
- package/dist/connection-sweep-do.js +89 -0
- package/dist/connection-sweep-do.js.map +1 -0
- package/dist/control-plane-do.d.ts +33 -42
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +104 -81
- package/dist/control-plane-do.js.map +1 -1
- package/dist/directory-mirror-apply.d.ts +59 -0
- package/dist/directory-mirror-apply.d.ts.map +1 -0
- package/dist/directory-mirror-apply.js +158 -0
- package/dist/directory-mirror-apply.js.map +1 -0
- package/dist/directory-mirror-claims.d.ts +77 -0
- package/dist/directory-mirror-claims.d.ts.map +1 -0
- package/dist/directory-mirror-claims.js +129 -0
- package/dist/directory-mirror-claims.js.map +1 -0
- package/dist/directory-mirror.d.ts +201 -0
- package/dist/directory-mirror.d.ts.map +1 -0
- package/dist/directory-mirror.js +557 -0
- package/dist/directory-mirror.js.map +1 -0
- package/dist/directory-objects.d.ts +24 -0
- package/dist/directory-objects.d.ts.map +1 -1
- package/dist/directory-objects.js +125 -1
- package/dist/directory-objects.js.map +1 -1
- package/dist/directory-placement.d.ts +17 -0
- package/dist/directory-placement.d.ts.map +1 -1
- package/dist/directory-placement.js +23 -2
- package/dist/directory-placement.js.map +1 -1
- package/dist/directory-split-inventory.d.ts +4 -1
- package/dist/directory-split-inventory.d.ts.map +1 -1
- package/dist/directory-split-inventory.js +7 -1
- package/dist/directory-split-inventory.js.map +1 -1
- package/dist/host.d.ts +2 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +43 -0
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kick-coalescer-do.d.ts +13 -3
- package/dist/kick-coalescer-do.d.ts.map +1 -1
- package/dist/kick-coalescer-do.js +20 -6
- package/dist/kick-coalescer-do.js.map +1 -1
- package/dist/peer-call-target.d.ts +61 -0
- package/dist/peer-call-target.d.ts.map +1 -0
- package/dist/peer-call-target.js +98 -0
- package/dist/peer-call-target.js.map +1 -0
- package/dist/route-read-model-publisher.d.ts +29 -4
- package/dist/route-read-model-publisher.d.ts.map +1 -1
- package/dist/route-read-model-publisher.js +137 -3
- package/dist/route-read-model-publisher.js.map +1 -1
- package/dist/route-read-model.d.ts +75 -1
- package/dist/route-read-model.d.ts.map +1 -1
- package/dist/route-read-model.js +118 -0
- package/dist/route-read-model.js.map +1 -1
- package/dist/route-resolver.d.ts +33 -5
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +130 -70
- package/dist/route-resolver.js.map +1 -1
- package/dist/scope-do.d.ts +8 -0
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +95 -4
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-wake.d.ts +127 -0
- package/dist/scope-wake.d.ts.map +1 -0
- package/dist/scope-wake.js +204 -0
- package/dist/scope-wake.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 3b of the directory split (K-68, directory split; rfc/tenant-scale.md §12): DUAL-WRITE.
|
|
3
|
+
* Every write to a row of the one directory (`ControlPlaneDO`) is also written to the object the
|
|
4
|
+
* row is placed in after the split (`directory-placement.ts`): its tenant's `TenantDirectoryDO`, or
|
|
5
|
+
* the `DirectoryRegistryDO`. The directory stays the only thing anything reads and the only place
|
|
6
|
+
* anything is decided. The objects are a copy, written after the directory's transaction commits.
|
|
7
|
+
*
|
|
8
|
+
* **Off by default.** `DIRECTORY_MIRROR` unset (or `off`) installs nothing, so a directory writes
|
|
9
|
+
* exactly what it wrote before this file existed. `all`, or a comma list of tables, switches it on.
|
|
10
|
+
*
|
|
11
|
+
* **Capture is triggers, as the routing read model's is (#3395).** An `AFTER INSERT/UPDATE/DELETE`
|
|
12
|
+
* trigger on each mirrored table appends (table, key, target object) to `directory_mirror_outbox` in
|
|
13
|
+
* the same transaction as the change, so no write path is missed and a path added later is covered
|
|
14
|
+
* without anyone remembering to. The triggers only append: no JSON is read and no constraint can be
|
|
15
|
+
* met (the outbox's key is its rowid), because a trigger that can fail is a directory write that can
|
|
16
|
+
* fail. The row itself is NOT copied: a `vertical_versions` manifest copied into an outbox would
|
|
17
|
+
* double the directory's largest writes and could carry a row past the object row limit.
|
|
18
|
+
*
|
|
19
|
+
* **The flush sends the CURRENT row, stamped with a version.** When the outermost directory method
|
|
20
|
+
* returns, the flush reads a batch of the outbox and, in the same synchronous transaction, bumps the
|
|
21
|
+
* directory's mirror version (one row a batch, not a row a write) and reads each key's row as it
|
|
22
|
+
* stands. Every change in the batch carries that version. The invariant that makes this correct:
|
|
23
|
+
* a row sent with version `v` reflects every directory write made before `v` was taken, and every
|
|
24
|
+
* write after it will be sent with a larger version. So the object applies a change only if its
|
|
25
|
+
* version is larger than the one it holds for that key, and keeps a tombstone (`deleted`) for a key
|
|
26
|
+
* it removed. Order and idempotency per row follow: a resend, a reordered delivery, or a second flush
|
|
27
|
+
* of the same key after a crash applies once and never goes back.
|
|
28
|
+
*
|
|
29
|
+
* A key's target is decided twice: at write time, by the trigger (so a delete knows where to go),
|
|
30
|
+
* and again at flush time over the current row, by the same SQL. A key the trigger sent to an object
|
|
31
|
+
* the current row is no longer placed in (a scope moved to another tenant, a row deleted) is sent
|
|
32
|
+
* there as a delete. A row no object takes (a tenant-placed row with no tenant, rfc §3's sweep-run
|
|
33
|
+
* units) is counted, never sent: `unplaced` in the flush report.
|
|
34
|
+
*
|
|
35
|
+
* **What is retried.** A send that fails leaves its outbox rows; they go to the back of the outbox
|
|
36
|
+
* (so one unreachable object never holds back the others), and the alarm retries after
|
|
37
|
+
* `MIRROR_RETRY_MS`. Only what an object confirmed is deleted from the outbox.
|
|
38
|
+
*
|
|
39
|
+
* **3c's backfill beside it** (not built here). A backfill page is read the same way: in one
|
|
40
|
+
* transaction, take a new version (`takeMirrorVersion`) and read the rows, then send them through the
|
|
41
|
+
* same `applyMirror`. A row written after the page was read has a larger version and wins; one
|
|
42
|
+
* written before it is in the page already. A key deleted after the page was read left a tombstone
|
|
43
|
+
* with a larger version, so the page cannot bring it back. The backfill and the dual-write therefore
|
|
44
|
+
* need no coordination and no cursor shared between them.
|
|
45
|
+
*
|
|
46
|
+
* **3d's comparison** reads, per tenant, every directory row whose `mirrorTargetsSql` names that
|
|
47
|
+
* tenant's object (the same SQL the triggers and the flush use, so the three cannot disagree about
|
|
48
|
+
* placement), and the object's own rows, and compares them key by key. A key with a row still in
|
|
49
|
+
* `directory_mirror_outbox` for that object, or parked in it, is in flight and reported apart, not as
|
|
50
|
+
* a difference.
|
|
51
|
+
*/
|
|
52
|
+
import { REGISTRY_OWNER, tenantOwnerOf } from '@substrat-run/kernel';
|
|
53
|
+
import { DIRECTORY_PLACEMENT } from './directory-placement.js';
|
|
54
|
+
/** The tables this owns in the directory. Excluded from a dump, kept across a restore. */
|
|
55
|
+
export const DIRECTORY_MIRROR_TABLE_GLOB = 'directory_mirror_*';
|
|
56
|
+
/** A crafted dump naming one of them is refused (`importDump`). */
|
|
57
|
+
export const isDirectoryMirrorTable = (name) => name.toLowerCase().startsWith('directory_mirror_');
|
|
58
|
+
/** How soon a failed send is tried again, by the alarm. */
|
|
59
|
+
export const MIRROR_RETRY_MS = 10_000;
|
|
60
|
+
/** Outbox rows one batch reads, and one flush at most (the rest go on the next kick). */
|
|
61
|
+
export const MIRROR_BATCH = 100;
|
|
62
|
+
export const MIRROR_FLUSH_MAX_ROWS = 1_000;
|
|
63
|
+
const REGISTRY = () => `'${REGISTRY_OWNER}'`;
|
|
64
|
+
const tenantPrefix = tenantOwnerOf('');
|
|
65
|
+
const TENANT = (ref) => `'${tenantPrefix}' || ${ref}."tenant_id"`;
|
|
66
|
+
/** rfc §3: "written in the object that changes (D or G)": a tenant's row in D, a platform row in G. */
|
|
67
|
+
const TENANT_OR_REGISTRY = (ref) => `CASE WHEN ${ref}."tenant_id" IS NULL THEN '${REGISTRY_OWNER}' ELSE '${tenantPrefix}' || ${ref}."tenant_id" END`;
|
|
68
|
+
const VIA_CONNECTION = (ref) => `'${tenantPrefix}' || (SELECT c.tenant_id FROM _substrat_connections c WHERE c.id = ${ref}."connection_id")`;
|
|
69
|
+
const viaScope = (column) => (ref) => `'${tenantPrefix}' || (SELECT s.tenant_id FROM scopes s WHERE s.scope_id = ${ref}."${column}")`;
|
|
70
|
+
/** `tenant:<id>` is its tenant's; `scope:<id>` its scope's tenant's; `directory:epoch` is the store's own. */
|
|
71
|
+
const LIFECYCLE_SUBJECT = (ref) => `CASE WHEN ${ref}."subject" GLOB 'tenant:*' THEN ${ref}."subject"
|
|
72
|
+
WHEN ${ref}."subject" GLOB 'scope:*' THEN '${tenantPrefix}' || (SELECT s.tenant_id FROM scopes s WHERE s.scope_id = substr(${ref}."subject", 7))
|
|
73
|
+
END`;
|
|
74
|
+
/** Placed tables whose route is not the default for their placement. */
|
|
75
|
+
const ROUTE_OVERRIDES = {
|
|
76
|
+
tenants: { targets: [REGISTRY, TENANT], note: 'G keeps the projection §7.3 sends a status to; D is authoritative' },
|
|
77
|
+
_substrat_access_log: { targets: [TENANT_OR_REGISTRY] },
|
|
78
|
+
_substrat_admin_log: { targets: [TENANT_OR_REGISTRY] },
|
|
79
|
+
_substrat_ops_failures: { targets: [TENANT_OR_REGISTRY] },
|
|
80
|
+
_substrat_markup_schedule: { targets: [TENANT_OR_REGISTRY], note: 'G for defaults (no tenant); per-tenant rows in D' },
|
|
81
|
+
_substrat_connection_secrets: { targets: [VIA_CONNECTION] },
|
|
82
|
+
_substrat_connection_keys: { targets: [VIA_CONNECTION] },
|
|
83
|
+
_substrat_connector_state: { targets: [VIA_CONNECTION] },
|
|
84
|
+
scope_lifecycle_receipts: { targets: [viaScope('scope_id')] },
|
|
85
|
+
scope_tenant_asks: { targets: [viaScope('scope_id')] },
|
|
86
|
+
scope_lifecycle_failures: { targets: [viaScope('scope_id')] },
|
|
87
|
+
_substrat_scope_object_reads: { targets: [viaScope('scope_id')] },
|
|
88
|
+
lifecycle_revisions: {
|
|
89
|
+
targets: [LIFECYCLE_SUBJECT],
|
|
90
|
+
note: '`directory:epoch` is not mirrored: each object mints its own epoch (directory-placement.ts)',
|
|
91
|
+
},
|
|
92
|
+
peer_bindings: {
|
|
93
|
+
targets: [TENANT, viaScope('target_scope_id')],
|
|
94
|
+
note: 'a cross-tenant binding lives in both tenants’ objects (placement: "both" read as both tenants)',
|
|
95
|
+
},
|
|
96
|
+
// Each object ships its own logs to the lake (K-70): copying the directory's queue would ship twice.
|
|
97
|
+
_substrat_directory_outbox: { notMirrored: 'each object keeps and ships its own lake outbox (K-70)' },
|
|
98
|
+
_substrat_directory_capture: { notMirrored: 'each object switches its own lake capture (K-70)' },
|
|
99
|
+
};
|
|
100
|
+
/** The route of a mirrored table, or null for one no object takes a copy of. */
|
|
101
|
+
export function mirrorRouteOf(table) {
|
|
102
|
+
const placement = DIRECTORY_PLACEMENT[table];
|
|
103
|
+
if (!placement)
|
|
104
|
+
throw new Error(`directory mirror: ${table} has no placement (K-68)`);
|
|
105
|
+
const override = ROUTE_OVERRIDES[table];
|
|
106
|
+
if (override)
|
|
107
|
+
return 'notMirrored' in override ? null : override;
|
|
108
|
+
switch (placement.to) {
|
|
109
|
+
case 'lake':
|
|
110
|
+
return null;
|
|
111
|
+
case 'registry':
|
|
112
|
+
return { targets: [REGISTRY] };
|
|
113
|
+
case 'tenant':
|
|
114
|
+
return { targets: [TENANT] };
|
|
115
|
+
case 'both':
|
|
116
|
+
throw new Error(`directory mirror: ${table} is placed in both objects and has no route saying which rows go where`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Every table the mirror can copy, in placement order. */
|
|
120
|
+
export const MIRRORED_TABLES = Object.keys(DIRECTORY_PLACEMENT).filter((t) => mirrorRouteOf(t) !== null);
|
|
121
|
+
/** The owner expressions of one row: what the triggers append and what 3d's comparison reads. */
|
|
122
|
+
export function mirrorTargetsSql(table, ref) {
|
|
123
|
+
const route = mirrorRouteOf(table);
|
|
124
|
+
if (!route)
|
|
125
|
+
throw new Error(`directory mirror: ${table} is not mirrored`);
|
|
126
|
+
return route.targets.map((t) => t(ref));
|
|
127
|
+
}
|
|
128
|
+
/** The object kind an owner names. */
|
|
129
|
+
export const objectKindOfOwner = (owner) => (owner === REGISTRY_OWNER ? 'registry' : 'tenant');
|
|
130
|
+
/**
|
|
131
|
+
* The switch as the control plane's environment spells it: unset, empty or `off` mirrors nothing;
|
|
132
|
+
* `all` mirrors every table; otherwise a comma list of `MIRRORED_TABLES`. A name it does not know
|
|
133
|
+
* is refused rather than ignored, so a typo cannot read as "on".
|
|
134
|
+
*/
|
|
135
|
+
export function parseDirectoryMirror(value) {
|
|
136
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
137
|
+
if (text === '' || text === 'off')
|
|
138
|
+
return [];
|
|
139
|
+
if (text === 'all')
|
|
140
|
+
return [...MIRRORED_TABLES];
|
|
141
|
+
const names = [...new Set(text.split(',').map((s) => s.trim()).filter((s) => s !== ''))];
|
|
142
|
+
const unknown = names.filter((n) => !MIRRORED_TABLES.includes(n));
|
|
143
|
+
if (unknown.length > 0)
|
|
144
|
+
throw new Error(`directory mirror: unknown or unmirrored table ${unknown.join(', ')} (or all, or off)`);
|
|
145
|
+
return names;
|
|
146
|
+
}
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// The directory's half: tables, triggers, the flush.
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
const OUTBOX = 'directory_mirror_outbox';
|
|
151
|
+
const STATE = 'directory_mirror_state';
|
|
152
|
+
const TABLES = 'directory_mirror_tables';
|
|
153
|
+
const CLAIMS_DUE = 'directory_mirror_claims_due';
|
|
154
|
+
const SOURCE_DDL = [
|
|
155
|
+
// Append-only: `id` is the rowid, so no trigger insert can meet a constraint. No index: the flush
|
|
156
|
+
// reads by id and acks by id, so an index would be one more row written for every directory write.
|
|
157
|
+
`CREATE TABLE IF NOT EXISTS ${OUTBOX} (id INTEGER PRIMARY KEY, tbl TEXT NOT NULL, row_key TEXT NOT NULL, target TEXT NOT NULL)`,
|
|
158
|
+
// `version` only grows: a flush batch (or a 3c backfill page) takes the next one. Kept across a
|
|
159
|
+
// restore (it describes the objects, not the directory), so a version is never handed out twice.
|
|
160
|
+
`CREATE TABLE IF NOT EXISTS ${STATE} (id INTEGER PRIMARY KEY CHECK (id = 1), version INTEGER NOT NULL, restored_at TEXT)`,
|
|
161
|
+
// Which tables mirror, and since when: a row written before `since` reached no object (3c fills it).
|
|
162
|
+
`CREATE TABLE IF NOT EXISTS ${TABLES} (tbl TEXT PRIMARY KEY, since TEXT NOT NULL)`,
|
|
163
|
+
// Owners whose object handed back registry claim work (part 2): drained after the rows, page by
|
|
164
|
+
// page until the object has none, so work beyond one page, or a round that failed, is never left
|
|
165
|
+
// waiting for that tenant's next write. A row per owner with work, written once until it is done.
|
|
166
|
+
`CREATE TABLE IF NOT EXISTS ${CLAIMS_DUE} (owner TEXT PRIMARY KEY, since TEXT NOT NULL)`,
|
|
167
|
+
];
|
|
168
|
+
const quoteIdent = (name) => `"${name.replaceAll('"', '""')}"`;
|
|
169
|
+
const triggerName = (verb, table) => `dmirror_${verb}_${table}`;
|
|
170
|
+
/** A table's key: its declared primary key, in order, or its rowid when it declares none. */
|
|
171
|
+
export function mirrorKeyColumns(sql, table) {
|
|
172
|
+
const cols = sql.exec(`SELECT name, pk FROM pragma_table_info(?)`, table).toArray();
|
|
173
|
+
if (cols.length === 0)
|
|
174
|
+
throw new Error(`directory mirror: no table ${table}`);
|
|
175
|
+
const pk = cols.filter((c) => c.pk > 0).sort((a, b) => a.pk - b.pk).map((c) => c.name);
|
|
176
|
+
return pk.length > 0 ? pk : ['rowid'];
|
|
177
|
+
}
|
|
178
|
+
const keySql = (keys, ref) => `json_array(${keys.map((k) => (k === 'rowid' ? `${ref}.rowid` : `${ref}.${quoteIdent(k)}`)).join(', ')})`;
|
|
179
|
+
/** The triggers one table needs, spelled as `sqlite_master` keeps them (compared text for text). */
|
|
180
|
+
export function directoryMirrorTriggerSql(sql, table) {
|
|
181
|
+
const keys = mirrorKeyColumns(sql, table);
|
|
182
|
+
const rows = (ref) => mirrorTargetsSql(table, ref).map((target) => `SELECT ${keySql(keys, ref)} AS k, ${target} AS x`);
|
|
183
|
+
// UNION, not UNION ALL: an update that changes neither key nor target appends one row, not two.
|
|
184
|
+
const append = (refs) => `INSERT INTO ${OUTBOX} (tbl, row_key, target) SELECT '${table}', k, x FROM (${refs.flatMap(rows).join(' UNION ')}) WHERE x IS NOT NULL;`;
|
|
185
|
+
const t = quoteIdent(table);
|
|
186
|
+
return [
|
|
187
|
+
{ name: triggerName('i', table), sql: `CREATE TRIGGER ${triggerName('i', table)} AFTER INSERT ON ${t} BEGIN ${append(['NEW'])} END` },
|
|
188
|
+
{ name: triggerName('u', table), sql: `CREATE TRIGGER ${triggerName('u', table)} AFTER UPDATE ON ${t} BEGIN ${append(['OLD', 'NEW'])} END` },
|
|
189
|
+
{ name: triggerName('d', table), sql: `CREATE TRIGGER ${triggerName('d', table)} AFTER DELETE ON ${t} BEGIN ${append(['OLD'])} END` },
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
function dropTriggers(sql, table) {
|
|
193
|
+
for (const verb of ['i', 'u', 'd'])
|
|
194
|
+
sql.exec(`DROP TRIGGER IF EXISTS ${triggerName(verb, table)}`);
|
|
195
|
+
}
|
|
196
|
+
/** Switch the mirror off on a directory that had it: its triggers go; its queue and version stay. */
|
|
197
|
+
export function uninstallDirectoryMirror(sql) {
|
|
198
|
+
// One read on every construction of a directory that never had the mirror, not 3 drops a table.
|
|
199
|
+
const triggers = sql.exec(`SELECT name FROM sqlite_master WHERE type = 'trigger' AND name GLOB 'dmirror_*'`).toArray();
|
|
200
|
+
for (const { name } of triggers)
|
|
201
|
+
sql.exec(`DROP TRIGGER IF EXISTS ${quoteIdent(name)}`);
|
|
202
|
+
const has = sql.exec(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?`, TABLES).toArray().length > 0;
|
|
203
|
+
if (has)
|
|
204
|
+
sql.exec(`DELETE FROM ${TABLES}`);
|
|
205
|
+
}
|
|
206
|
+
/** Take the next version, inside the caller's transaction (a flush batch, a 3c backfill page). */
|
|
207
|
+
export function takeMirrorVersion(sql) {
|
|
208
|
+
sql.exec(`UPDATE ${STATE} SET version = version + 1 WHERE id = 1`);
|
|
209
|
+
return Number(sql.exec(`SELECT version FROM ${STATE} WHERE id = 1`).one().version);
|
|
210
|
+
}
|
|
211
|
+
/** How many owners one flush drains claim work for, and how many pages each at most. */
|
|
212
|
+
export const MIRROR_CLAIM_OWNERS_PER_FLUSH = 20;
|
|
213
|
+
export const MIRROR_CLAIM_PAGES_PER_OWNER = 10;
|
|
214
|
+
const emptyFlush = () => ({
|
|
215
|
+
read: 0, acked: 0, sent: 0, applied: 0, stale: 0, parked: 0, healed: 0, unplaced: 0,
|
|
216
|
+
claims: { claimed: 0, refused: 0, released: 0, errors: 0 },
|
|
217
|
+
rowsWrittenDirectory: 0, rowsWrittenObjects: 0, deferred: false, failed: [],
|
|
218
|
+
});
|
|
219
|
+
/** The directory's half, one per `ControlPlaneDO` instance while the switch is on. */
|
|
220
|
+
export class DirectoryMirror {
|
|
221
|
+
options;
|
|
222
|
+
sql;
|
|
223
|
+
keys = new Map();
|
|
224
|
+
flushing = null;
|
|
225
|
+
again = false;
|
|
226
|
+
retryAfter = 0;
|
|
227
|
+
/** The last flush's account, for status and tests. */
|
|
228
|
+
last = null;
|
|
229
|
+
constructor(options) {
|
|
230
|
+
this.options = options;
|
|
231
|
+
this.sql = options.sql;
|
|
232
|
+
}
|
|
233
|
+
now() {
|
|
234
|
+
return (this.options.now ?? Date.now)();
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Create the tables and hold the triggers to the switch, in the caller's transaction: a table
|
|
238
|
+
* switched on gets its triggers and `since = now`, one switched off loses them. Writes nothing
|
|
239
|
+
* when nothing changed. Run on construction and after a restore (whose drops took the triggers).
|
|
240
|
+
*/
|
|
241
|
+
install() {
|
|
242
|
+
for (const stmt of SOURCE_DDL)
|
|
243
|
+
this.sql.exec(stmt);
|
|
244
|
+
this.sql.exec(`INSERT OR IGNORE INTO ${STATE} (id, version, restored_at) VALUES (1, 0, NULL)`);
|
|
245
|
+
const before = new Set(this.sql.exec(`SELECT tbl FROM ${TABLES}`).toArray().map((r) => r.tbl));
|
|
246
|
+
const want = new Set(this.options.tables);
|
|
247
|
+
const enabled = [];
|
|
248
|
+
const disabled = [];
|
|
249
|
+
const at = new Date(this.now()).toISOString();
|
|
250
|
+
for (const table of MIRRORED_TABLES) {
|
|
251
|
+
if (!want.has(table)) {
|
|
252
|
+
dropTriggers(this.sql, table);
|
|
253
|
+
if (before.has(table)) {
|
|
254
|
+
this.sql.exec(`DELETE FROM ${TABLES} WHERE tbl = ?`, table);
|
|
255
|
+
disabled.push(table);
|
|
256
|
+
}
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
for (const t of directoryMirrorTriggerSql(this.sql, table)) {
|
|
260
|
+
const held = this.sql.exec(`SELECT sql FROM sqlite_master WHERE type = 'trigger' AND name = ?`, t.name).toArray()[0];
|
|
261
|
+
if (held?.sql === t.sql)
|
|
262
|
+
continue;
|
|
263
|
+
this.sql.exec(`DROP TRIGGER IF EXISTS ${t.name}`);
|
|
264
|
+
this.sql.exec(t.sql);
|
|
265
|
+
}
|
|
266
|
+
if (!before.has(table)) {
|
|
267
|
+
this.sql.exec(`INSERT INTO ${TABLES} (tbl, since) VALUES (?, ?)`, table, at);
|
|
268
|
+
enabled.push(table);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return { enabled, disabled };
|
|
272
|
+
}
|
|
273
|
+
/** A restore replaced the directory: every object now differs from it until 3c fills them again. */
|
|
274
|
+
markRestored() {
|
|
275
|
+
this.sql.exec(`UPDATE ${STATE} SET restored_at = ? WHERE id = 1`, new Date(this.now()).toISOString());
|
|
276
|
+
}
|
|
277
|
+
pending() {
|
|
278
|
+
return (this.sql.exec(`SELECT 1 FROM ${OUTBOX} LIMIT 1`).toArray().length > 0 ||
|
|
279
|
+
this.sql.exec(`SELECT 1 FROM ${CLAIMS_DUE} LIMIT 1`).toArray().length > 0);
|
|
280
|
+
}
|
|
281
|
+
status() {
|
|
282
|
+
const state = this.sql.exec(`SELECT version, restored_at FROM ${STATE} WHERE id = 1`).one();
|
|
283
|
+
const q = this.sql.exec(`SELECT COUNT(*) AS n, MIN(id) AS oldest FROM ${OUTBOX}`).one();
|
|
284
|
+
return {
|
|
285
|
+
enabled: true,
|
|
286
|
+
tables: this.sql.exec(`SELECT tbl, since FROM ${TABLES} ORDER BY tbl`).toArray().map((r) => ({ table: r.tbl, since: r.since })),
|
|
287
|
+
version: Number(state.version),
|
|
288
|
+
restoredAt: state.restored_at,
|
|
289
|
+
queued: Number(q.n),
|
|
290
|
+
oldestQueuedId: q.oldest === null ? null : Number(q.oldest),
|
|
291
|
+
claimsDue: Number(this.sql.exec(`SELECT COUNT(*) AS n FROM ${CLAIMS_DUE}`).one().n),
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
keyColumns(table) {
|
|
295
|
+
let keys = this.keys.get(table);
|
|
296
|
+
if (!keys) {
|
|
297
|
+
keys = mirrorKeyColumns(this.sql, table);
|
|
298
|
+
this.keys.set(table, keys);
|
|
299
|
+
}
|
|
300
|
+
return keys;
|
|
301
|
+
}
|
|
302
|
+
/** The row a key names as it stands, and the owners it is placed in now. */
|
|
303
|
+
readCurrent(table, key) {
|
|
304
|
+
const keys = this.keyColumns(table);
|
|
305
|
+
const values = JSON.parse(key);
|
|
306
|
+
const where = keys.map((k) => (k === 'rowid' ? 't.rowid = ?' : `t.${quoteIdent(k)} IS ?`)).join(' AND ');
|
|
307
|
+
const targets = mirrorTargetsSql(table, 't').map((expr, i) => `${expr} AS "__mirror_t${i}"`);
|
|
308
|
+
const rowid = keys[0] === 'rowid' ? ', t.rowid AS "__mirror_rowid"' : '';
|
|
309
|
+
const found = this.sql.exec(`SELECT t.*${rowid}, ${targets.join(', ')} FROM ${quoteIdent(table)} t WHERE ${where}`, ...values).toArray()[0];
|
|
310
|
+
if (!found)
|
|
311
|
+
return { row: null, owners: new Set() };
|
|
312
|
+
const row = {};
|
|
313
|
+
const owners = new Set();
|
|
314
|
+
for (const [column, value] of Object.entries(found)) {
|
|
315
|
+
if (column.startsWith('__mirror_t')) {
|
|
316
|
+
if (typeof value === 'string')
|
|
317
|
+
owners.add(value);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (value instanceof ArrayBuffer)
|
|
321
|
+
throw new Error(`directory mirror: ${table}.${column} holds a BLOB, which the mirror does not carry`);
|
|
322
|
+
row[column === '__mirror_rowid' ? 'rowid' : column] = value;
|
|
323
|
+
}
|
|
324
|
+
return { row, owners };
|
|
325
|
+
}
|
|
326
|
+
/** One batch, read in one transaction: the version, then each key's current row. */
|
|
327
|
+
readBatch(limit) {
|
|
328
|
+
const rows = this.sql.exec(`SELECT id, tbl, row_key, target FROM ${OUTBOX} ORDER BY id LIMIT ?`, limit).toArray();
|
|
329
|
+
if (rows.length === 0)
|
|
330
|
+
return null;
|
|
331
|
+
const version = takeMirrorVersion(this.sql);
|
|
332
|
+
const byOwner = new Map();
|
|
333
|
+
const current = new Map();
|
|
334
|
+
const seen = new Set();
|
|
335
|
+
let unplaced = 0;
|
|
336
|
+
for (const r of rows) {
|
|
337
|
+
const slot = byOwner.get(r.target) ?? { changes: [], ids: [] };
|
|
338
|
+
byOwner.set(r.target, slot);
|
|
339
|
+
slot.ids.push(r.id);
|
|
340
|
+
// Once per (owner, key) a batch, in the order the keys were first written.
|
|
341
|
+
const once = `${r.target}\u0000${r.tbl}\u0000${r.row_key}`;
|
|
342
|
+
if (seen.has(once))
|
|
343
|
+
continue;
|
|
344
|
+
seen.add(once);
|
|
345
|
+
const keyId = `${r.tbl}\u0000${r.row_key}`;
|
|
346
|
+
let now = current.get(keyId);
|
|
347
|
+
if (!now) {
|
|
348
|
+
now = this.readCurrent(r.tbl, r.row_key);
|
|
349
|
+
current.set(keyId, now);
|
|
350
|
+
if (now.row && now.owners.size === 0)
|
|
351
|
+
unplaced += 1;
|
|
352
|
+
}
|
|
353
|
+
slot.changes.push({ table: r.tbl, key: r.row_key, row: now.owners.has(r.target) ? now.row : null });
|
|
354
|
+
}
|
|
355
|
+
return { ids: rows.map((r) => r.id), version, byOwner, unplaced };
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Send what the outbox holds, batch by batch, up to `maxRows`. Throws once every send it started
|
|
359
|
+
* has settled when any was refused: what an object confirmed is acknowledged, the rest has moved
|
|
360
|
+
* to the back of the outbox.
|
|
361
|
+
*/
|
|
362
|
+
async flush(maxRows = MIRROR_FLUSH_MAX_ROWS) {
|
|
363
|
+
const out = emptyFlush();
|
|
364
|
+
const failed = new Map();
|
|
365
|
+
while (out.read < maxRows) {
|
|
366
|
+
if (!this.options.quiet()) {
|
|
367
|
+
out.deferred = true;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
const batch = this.options.transaction(() => this.readBatch(Math.min(MIRROR_BATCH, maxRows - out.read)));
|
|
371
|
+
if (!batch)
|
|
372
|
+
break;
|
|
373
|
+
out.rowsWrittenDirectory += 1; // the version
|
|
374
|
+
out.read += batch.ids.length;
|
|
375
|
+
out.unplaced += batch.unplaced;
|
|
376
|
+
const owners = [...batch.byOwner.keys()].filter((owner) => !failed.has(owner));
|
|
377
|
+
const settled = await Promise.allSettled(owners.map((owner) => this.options.sender.send(owner, { version: batch.version, changes: batch.byOwner.get(owner).changes })));
|
|
378
|
+
const ack = [];
|
|
379
|
+
const back = [];
|
|
380
|
+
const claimsDue = [];
|
|
381
|
+
for (const [owner, slot] of batch.byOwner) {
|
|
382
|
+
const i = owners.indexOf(owner);
|
|
383
|
+
const r = i >= 0 ? settled[i] : null;
|
|
384
|
+
if (r && r.status === 'fulfilled') {
|
|
385
|
+
ack.push(...slot.ids);
|
|
386
|
+
out.sent += slot.changes.length;
|
|
387
|
+
out.applied += r.value.applied;
|
|
388
|
+
out.stale += r.value.stale;
|
|
389
|
+
out.parked += r.value.parked;
|
|
390
|
+
out.healed += r.value.healed;
|
|
391
|
+
out.rowsWrittenObjects += r.value.rowsWritten;
|
|
392
|
+
const claims = r.value.claims;
|
|
393
|
+
if (claims && (claims.crossings.length > 0 || claims.releases.length > 0))
|
|
394
|
+
claimsDue.push(owner);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
if (r && r.status === 'rejected')
|
|
398
|
+
failed.set(owner, r.reason);
|
|
399
|
+
back.push(...slot.ids);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (back.length > 0) {
|
|
403
|
+
// To the back: fresh rows behind everything queued, the rows this attempt read removed.
|
|
404
|
+
const list = JSON.stringify(back);
|
|
405
|
+
out.rowsWrittenDirectory += this.options.transaction(() => {
|
|
406
|
+
const moved = this.sql.exec(`INSERT INTO ${OUTBOX} (tbl, row_key, target) SELECT tbl, row_key, target FROM ${OUTBOX} WHERE id IN (SELECT value FROM json_each(?)) ORDER BY id`, list).rowsWritten;
|
|
407
|
+
return moved + this.sql.exec(`DELETE FROM ${OUTBOX} WHERE id IN (SELECT value FROM json_each(?))`, list).rowsWritten;
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
if (ack.length > 0) {
|
|
411
|
+
// The owners with claim work are recorded due in the same transaction as the ack, so a row is
|
|
412
|
+
// never acknowledged while the claims it made are scheduled nowhere.
|
|
413
|
+
out.rowsWrittenDirectory += this.options.transaction(() => {
|
|
414
|
+
const at = new Date(this.now()).toISOString();
|
|
415
|
+
let n = 0;
|
|
416
|
+
for (const owner of claimsDue)
|
|
417
|
+
n += this.sql.exec(`INSERT OR IGNORE INTO ${CLAIMS_DUE} (owner, since) VALUES (?, ?)`, owner, at).rowsWritten;
|
|
418
|
+
return n + this.sql.exec(`DELETE FROM ${OUTBOX} WHERE id IN (SELECT value FROM json_each(?))`, JSON.stringify(ack)).rowsWritten;
|
|
419
|
+
});
|
|
420
|
+
out.acked += ack.length;
|
|
421
|
+
}
|
|
422
|
+
// A batch that landed nothing while an object refuses: stop, and let the alarm try again.
|
|
423
|
+
if (ack.length === 0 && failed.size > 0)
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
// The rows are in; the claims they made are host code's (rfc §7.3), never inside a transaction.
|
|
427
|
+
if (!out.deferred)
|
|
428
|
+
await this.drainClaims(out, failed);
|
|
429
|
+
out.failed = [...failed.keys()];
|
|
430
|
+
this.last = out;
|
|
431
|
+
if (failed.size > 0) {
|
|
432
|
+
const [first] = failed.values();
|
|
433
|
+
throw new Error(`directory mirror: ${failed.size} object(s) refused a batch; retried from the alarm. First: ${String(first)}`);
|
|
434
|
+
}
|
|
435
|
+
return out;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Drain the registry claim work of the owners recorded due, page by page, until each object reports
|
|
439
|
+
* none. A round that throws, or settles nothing while work is left, is a failure: the owner stays
|
|
440
|
+
* due and the flush throws, so the alarm retries it. A refusal settles its crossing and is progress.
|
|
441
|
+
*/
|
|
442
|
+
async drainClaims(out, failed) {
|
|
443
|
+
const { sender } = this.options;
|
|
444
|
+
if (!sender.settleClaims || !sender.claimWork)
|
|
445
|
+
return;
|
|
446
|
+
const due = this.sql.exec(`SELECT owner FROM ${CLAIMS_DUE} ORDER BY since, owner LIMIT ?`, MIRROR_CLAIM_OWNERS_PER_FLUSH).toArray();
|
|
447
|
+
for (const { owner } of due) {
|
|
448
|
+
if (failed.has(owner))
|
|
449
|
+
continue;
|
|
450
|
+
try {
|
|
451
|
+
let empty = false;
|
|
452
|
+
for (let page = 0; page < MIRROR_CLAIM_PAGES_PER_OWNER; page++) {
|
|
453
|
+
const work = await sender.claimWork(owner);
|
|
454
|
+
if (work.crossings.length === 0 && work.releases.length === 0) {
|
|
455
|
+
empty = true;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
const c = await sender.settleClaims([{ owner, claims: work }]);
|
|
459
|
+
out.claims.claimed += c.claimed;
|
|
460
|
+
out.claims.refused += c.refused;
|
|
461
|
+
out.claims.released += c.released;
|
|
462
|
+
out.claims.errors += c.errors;
|
|
463
|
+
if (c.errors > 0 || c.claimed + c.refused + c.released === 0) {
|
|
464
|
+
throw new Error(`registry claim work of ${owner} made no progress (${c.errors} error(s))`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
// Drained, or more pages than one flush gives an owner: those stay due for the next flush.
|
|
468
|
+
if (empty)
|
|
469
|
+
out.rowsWrittenDirectory += this.sql.exec(`DELETE FROM ${CLAIMS_DUE} WHERE owner = ?`, owner).rowsWritten;
|
|
470
|
+
}
|
|
471
|
+
catch (err) {
|
|
472
|
+
console.error('directory mirror: registry claims failed, retried from the alarm', err);
|
|
473
|
+
failed.set(owner, err);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Called when the directory's outermost method returns. One flush at a time: a kick during a
|
|
479
|
+
* flush runs one more round after it. After a failure only the alarm retries (`retry`).
|
|
480
|
+
*/
|
|
481
|
+
kick() {
|
|
482
|
+
if (this.now() < this.retryAfter)
|
|
483
|
+
return;
|
|
484
|
+
if (this.flushing) {
|
|
485
|
+
this.again = true;
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (!this.pending())
|
|
489
|
+
return;
|
|
490
|
+
void this.own(async () => {
|
|
491
|
+
let result;
|
|
492
|
+
do {
|
|
493
|
+
this.again = false;
|
|
494
|
+
result = await this.flush();
|
|
495
|
+
} while (!result.deferred && (this.again || result.read >= MIRROR_FLUSH_MAX_ROWS));
|
|
496
|
+
return result;
|
|
497
|
+
}).catch(async (err) => {
|
|
498
|
+
console.error('directory mirror: a send failed, retrying from the alarm', err);
|
|
499
|
+
this.retryAfter = this.now() + MIRROR_RETRY_MS;
|
|
500
|
+
await this.options.armRetry(this.now() + MIRROR_RETRY_MS).catch(() => undefined);
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
/** The alarm's half: lift the backoff and flush. */
|
|
504
|
+
retry() {
|
|
505
|
+
this.retryAfter = 0;
|
|
506
|
+
this.kick();
|
|
507
|
+
}
|
|
508
|
+
/** Wait until the outbox is drained, or a flush fails (for a caller, and a test, that must see it land). */
|
|
509
|
+
async settle() {
|
|
510
|
+
this.retryAfter = 0;
|
|
511
|
+
let last = null;
|
|
512
|
+
while (this.pending()) {
|
|
513
|
+
last = await this.own(() => this.flush());
|
|
514
|
+
if (last.deferred)
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
return last;
|
|
518
|
+
}
|
|
519
|
+
async own(flush) {
|
|
520
|
+
while (this.flushing)
|
|
521
|
+
await this.flushing.catch(() => undefined);
|
|
522
|
+
const run = flush();
|
|
523
|
+
this.flushing = run;
|
|
524
|
+
try {
|
|
525
|
+
return await run;
|
|
526
|
+
}
|
|
527
|
+
finally {
|
|
528
|
+
this.flushing = null;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* The directory's mirror as its environment sets it: null (and every mirror trigger dropped) when
|
|
534
|
+
* `DIRECTORY_MIRROR` is off, refused, or the objects are not bound; otherwise installed and ready to
|
|
535
|
+
* kick. Called once, from `ControlPlaneDO`'s constructor.
|
|
536
|
+
*/
|
|
537
|
+
export function directoryMirrorFor(env, sender, options) {
|
|
538
|
+
let tables;
|
|
539
|
+
try {
|
|
540
|
+
tables = parseDirectoryMirror(Reflect.get(env, 'DIRECTORY_MIRROR'));
|
|
541
|
+
}
|
|
542
|
+
catch (err) {
|
|
543
|
+
console.error('directory mirror: DIRECTORY_MIRROR refused, the mirror stays off:', err.message);
|
|
544
|
+
tables = [];
|
|
545
|
+
}
|
|
546
|
+
if (tables.length > 0 && !sender) {
|
|
547
|
+
console.error('directory mirror: DIRECTORY_MIRROR is on but DIRECTORY_REGISTRY / TENANT_DIRECTORY are not bound; the mirror stays off');
|
|
548
|
+
}
|
|
549
|
+
if (tables.length === 0 || !sender) {
|
|
550
|
+
options.transaction(() => uninstallDirectoryMirror(options.sql));
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
const mirror = new DirectoryMirror({ ...options, tables, sender });
|
|
554
|
+
options.transaction(() => mirror.install());
|
|
555
|
+
return mirror;
|
|
556
|
+
}
|
|
557
|
+
//# sourceMappingURL=directory-mirror.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-mirror.js","sourceRoot":"","sources":["../src/directory-mirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAA4B,MAAM,0BAA0B,CAAC;AAGzF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,CAAC;AAChE,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;AAEpH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,yFAAyF;AACzF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAS3C,MAAM,QAAQ,GAAc,GAAG,EAAE,CAAC,IAAI,cAAc,GAAG,CAAC;AACxD,MAAM,YAAY,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;AACvC,MAAM,MAA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,MAA2B,EAC3B,OAA0D;IAE1D,IAAI,MAAgB,CAAC;IACrB,IAAI,CAAC;QACH,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,GAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAChF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,mEAAmE,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;QAC3G,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,wHAAwH,CAAC,CAAC;IAC1I,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -22,14 +22,28 @@ import { DurableObject } from 'cloudflare:workers';
|
|
|
22
22
|
import type { Jurisdiction } from '@substrat-run/contracts';
|
|
23
23
|
import { type ClaimInput, type ClaimNamespace, type ClaimOutcome, type ClaimRow, type ConfirmInput, type ConfirmOutcome, type CrossingInput, type CrossingRow, type DirectoryObjects, type ReleaseInput, type SettleInput, type SwitchSql } from '@substrat-run/kernel';
|
|
24
24
|
import { type DirectoryObjectKind } from './directory-placement.js';
|
|
25
|
+
import { type MirrorTargetStatus } from './directory-mirror-apply.js';
|
|
26
|
+
import type { MirrorApplyResult, MirrorBatch, MirrorSender } from './directory-mirror.js';
|
|
27
|
+
import { type MirrorClaimWork, type MirrorRelease } from './directory-mirror-claims.js';
|
|
25
28
|
/** The registry's object name. */
|
|
26
29
|
export declare const REGISTRY_OBJECT_NAME = "registry";
|
|
27
30
|
/** A tenant directory object's name (rfc §7.1). */
|
|
28
31
|
export declare const tenantDirectoryNameOf: (tenantId: string) => string;
|
|
29
32
|
declare abstract class DirectoryObjectBase extends DurableObject {
|
|
33
|
+
protected readonly kind: DirectoryObjectKind;
|
|
30
34
|
protected readonly sql: SqlStorage;
|
|
31
35
|
protected readonly kernelSql: SwitchSql;
|
|
36
|
+
/** The directory tables placed in this object: the only ones the dual-write may write (step 3b). */
|
|
37
|
+
private readonly placed;
|
|
32
38
|
constructor(ctx: DurableObjectState, env: unknown, kind: DirectoryObjectKind);
|
|
39
|
+
/**
|
|
40
|
+
* Step 3b (K-68): apply a batch the directory's dual-write sent (`directory-mirror.ts`). Each
|
|
41
|
+
* change applies once and never backwards (`directory-mirror-apply.ts`). Binds an unbound object to
|
|
42
|
+
* its owner, as a crossing does: the first write an object takes decides whose it is.
|
|
43
|
+
*/
|
|
44
|
+
applyMirror(owner: string, jurisdiction: Jurisdiction, batch: MirrorBatch): MirrorApplyResult;
|
|
45
|
+
/** What the dual-write has left here: rows, tombstones, and changes parked for want of a parent. */
|
|
46
|
+
mirrorStatus(): MirrorTargetStatus;
|
|
33
47
|
/** Refuse a call meant for another object; bind this one to its owner on the first write. */
|
|
34
48
|
protected assertOwner(owner: string, jurisdiction: Jurisdiction, bind: boolean): void;
|
|
35
49
|
recordCrossing(owner: string, jurisdiction: Jurisdiction, input: CrossingInput): CrossingRow;
|
|
@@ -54,6 +68,10 @@ export declare class DirectoryRegistryDO extends DirectoryObjectBase {
|
|
|
54
68
|
/** One per tenant (rfc §7.1): everything that is the tenant's. */
|
|
55
69
|
export declare class TenantDirectoryDO extends DirectoryObjectBase {
|
|
56
70
|
constructor(ctx: DurableObjectState, env: unknown);
|
|
71
|
+
/** Step 3b: one page of the registry claim work this object owes, asked until it is empty. */
|
|
72
|
+
mirrorClaimWork(owner: string, jurisdiction: Jurisdiction): MirrorClaimWork;
|
|
73
|
+
/** Step 3b: the registry answered a release this object owes; drop it once it is done (`directory-mirror-claims.ts`). */
|
|
74
|
+
settleMirrorRelease(owner: string, jurisdiction: Jurisdiction, release: MirrorRelease, released: boolean): boolean;
|
|
57
75
|
}
|
|
58
76
|
/** The registry's stub. */
|
|
59
77
|
export declare function registryStub(ns: DurableObjectNamespace<DirectoryRegistryDO>): DurableObjectStub<DirectoryRegistryDO>;
|
|
@@ -70,5 +88,11 @@ export declare function durableDirectoryObjects(options: {
|
|
|
70
88
|
tenants: DurableObjectNamespace<TenantDirectoryDO>;
|
|
71
89
|
jurisdictionOf?: (tenantId: string) => Jurisdiction;
|
|
72
90
|
}): DirectoryObjects;
|
|
91
|
+
/**
|
|
92
|
+
* Step 3b: how the directory's dual-write reaches the objects (`directory-mirror.ts`), or null where
|
|
93
|
+
* the two namespaces are not bound. Every tenant object is addressed `global`, as `durableDirectoryObjects`
|
|
94
|
+
* does until a tenant's jurisdiction is recorded (the only one the provisioning boundary accepts).
|
|
95
|
+
*/
|
|
96
|
+
export declare function durableMirrorSender(env: unknown): MirrorSender | null;
|
|
73
97
|
export {};
|
|
74
98
|
//# sourceMappingURL=directory-objects.d.ts.map
|