@substrat-run/adapter-cloudflare 0.213.0 → 0.215.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/control-plane-do.d.ts +89 -6
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +310 -12
- package/dist/control-plane-do.js.map +1 -1
- package/dist/directory-split-inventory.d.ts +2 -2
- package/dist/directory-split-inventory.d.ts.map +1 -1
- package/dist/directory-split-inventory.js +8 -2
- package/dist/directory-split-inventory.js.map +1 -1
- package/dist/host.d.ts +5 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +46 -2
- 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 +3 -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/reconcile-on-wake.d.ts +35 -0
- package/dist/reconcile-on-wake.d.ts.map +1 -0
- package/dist/reconcile-on-wake.js +75 -0
- package/dist/reconcile-on-wake.js.map +1 -0
- package/dist/route-read-model-publisher.d.ts +171 -0
- package/dist/route-read-model-publisher.d.ts.map +1 -0
- package/dist/route-read-model-publisher.js +524 -0
- package/dist/route-read-model-publisher.js.map +1 -0
- package/dist/route-read-model.d.ts +166 -0
- package/dist/route-read-model.d.ts.map +1 -0
- package/dist/route-read-model.js +195 -0
- package/dist/route-read-model.js.map +1 -0
- package/dist/route-resolver.d.ts +41 -3
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +58 -3
- 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 +133 -6
- 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 +9 -9
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control plane's half of the routing read model (#3395): it captures every directory change
|
|
3
|
+
* that moves a route or a vertical's serving policy, and publishes the result to Workers KV.
|
|
4
|
+
*
|
|
5
|
+
* **Capture is a mechanism, not a list of call sites.** SQLite triggers on the five tables the
|
|
6
|
+
* route read joins (`hostnames`, `scopes`, `tenants`, `verticals`, `vertical_versions`) append the
|
|
7
|
+
* affected keys to an outbox in the same transaction as the change: a hostname bound, activated or
|
|
8
|
+
* removed, a scope bound, re-pointed, forked, suspended or reaped, a tenant's status, a promote.
|
|
9
|
+
* A write path added later is captured without anyone remembering to.
|
|
10
|
+
*
|
|
11
|
+
* The triggers do nothing but append. They read no JSON and meet no constraint (the outbox's key
|
|
12
|
+
* is its rowid), because a trigger that can fail is a directory write that can fail. An outer
|
|
13
|
+
* statement's `OR IGNORE` would also override an inner conflict clause (SQLite), so an upserting
|
|
14
|
+
* outbox could silently drop a re-dirty; an append cannot.
|
|
15
|
+
*
|
|
16
|
+
* **Publishing** recomputes each dirty key from the directory, compares a digest with the last one
|
|
17
|
+
* published, and writes or deletes the KV entry only on a change. A key leaves the outbox only up
|
|
18
|
+
* to the row it was read at, so a change made while its publish was in flight is published again.
|
|
19
|
+
*
|
|
20
|
+
* **Residency (K-36).** A route whose hostname region or scope jurisdiction is pinned (`eu`, `us`)
|
|
21
|
+
* is never written: KV has no jurisdiction. The router reads such a route from the directory.
|
|
22
|
+
*
|
|
23
|
+
* The ledger of what was published (`route_read_model_published`) describes KV, not the
|
|
24
|
+
* directory, so a directory dump does not carry it and a restore does not drop it — the way the
|
|
25
|
+
* lifecycle epoch is the store's and not the data's. A restore then marks every key dirty, which
|
|
26
|
+
* re-publishes the restored directory AND deletes every route it no longer holds.
|
|
27
|
+
*/
|
|
28
|
+
import { ROUTE_SCOPE_HOSTNAMES_MAX } from '@substrat-run/contracts';
|
|
29
|
+
import { isPrimaryScopeRow } from '@substrat-run/kernel';
|
|
30
|
+
import { ROUTE_READ_MODEL_VERSION, routeKvKey, servingPolicyKvKey, } from './route-read-model.js';
|
|
31
|
+
/** The tables this owns. Excluded from a directory dump, and from a restore's drop. */
|
|
32
|
+
export const ROUTE_READ_MODEL_TABLE_GLOB = 'route_read_model_*';
|
|
33
|
+
/** A binding that looks like KV, or nothing: the read model is on only where one is bound. */
|
|
34
|
+
export function routeKvWriterOf(value) {
|
|
35
|
+
if (typeof value !== 'object' || value === null)
|
|
36
|
+
return null;
|
|
37
|
+
const ok = ['get', 'put', 'delete'].every((m) => typeof Reflect.get(value, m) === 'function');
|
|
38
|
+
return ok ? value : null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The KV key naming which ledger the namespace's entries were confirmed by. The ledger keeps the
|
|
42
|
+
* same id; a namespace whose marker differs (or is missing) is not the one the ledger describes —
|
|
43
|
+
* the `ROUTES` binding was pointed at another namespace — so the ledger is cleared and every key
|
|
44
|
+
* republished. The router never reads it (it is no route entry).
|
|
45
|
+
*/
|
|
46
|
+
export const ROUTE_LEDGER_MARKER_KEY = 'route/v1/meta/ledger';
|
|
47
|
+
const LEDGER_SOURCE = 'ledger-namespace';
|
|
48
|
+
const TABLES_DDL = [
|
|
49
|
+
// Append-only: `id` is the rowid, so no insert here can meet a constraint.
|
|
50
|
+
`CREATE TABLE IF NOT EXISTS route_read_model_outbox (id INTEGER PRIMARY KEY, key TEXT NOT NULL)`,
|
|
51
|
+
`CREATE INDEX IF NOT EXISTS route_read_model_outbox_key ON route_read_model_outbox (key, id)`,
|
|
52
|
+
`CREATE TABLE IF NOT EXISTS route_read_model_published (key TEXT PRIMARY KEY, digest TEXT NOT NULL, at TEXT NOT NULL)`,
|
|
53
|
+
// The reconcile pass's position in each source, so a pass resumes where the last one stopped.
|
|
54
|
+
`CREATE TABLE IF NOT EXISTS route_read_model_cursor (source TEXT PRIMARY KEY, after TEXT NOT NULL)`,
|
|
55
|
+
// The version trigger re-reads the legacy scopes bound to a version; without this, a scan.
|
|
56
|
+
`CREATE INDEX IF NOT EXISTS scopes_vertical_version ON scopes (vertical_version_id)`,
|
|
57
|
+
];
|
|
58
|
+
const append = (select) => `INSERT INTO route_read_model_outbox (key) ${select};`;
|
|
59
|
+
const hostnamesOfScope = (scope) => append(`SELECT 'h:' || hostname FROM hostnames WHERE scope_id = ${scope}`);
|
|
60
|
+
const hostnamesOfTenant = (tenant) => append(`SELECT 'h:' || h.hostname FROM scopes s JOIN hostnames h ON h.scope_id = s.scope_id WHERE s.tenant_id = ${tenant}`);
|
|
61
|
+
/** A version moves the verticals it serves, and the legacy scopes that run it on its own script. */
|
|
62
|
+
const dependentsOfVersion = (row) => append(`SELECT 'v:' || slug FROM verticals WHERE serving_version_id = ${row}.id`) +
|
|
63
|
+
append(`SELECT 'h:' || h.hostname FROM scopes s JOIN hostnames h ON h.scope_id = s.scope_id
|
|
64
|
+
WHERE s.vertical_version_id = ${row}.id AND s.serving_ref IS NULL`);
|
|
65
|
+
/**
|
|
66
|
+
* Every column the route read uses is in an `UPDATE OF` list, and no other: a scope's row is
|
|
67
|
+
* updated for its migration bookkeeping far more often than it is re-routed.
|
|
68
|
+
*/
|
|
69
|
+
const TRIGGERS = [
|
|
70
|
+
// `INSERT OR REPLACE` deletes the old row without firing a DELETE trigger (recursive triggers
|
|
71
|
+
// are off), so a hostname re-bound to another scope would leave its old scope's siblings listing
|
|
72
|
+
// it. BEFORE the insert, the old row is still there to name that scope.
|
|
73
|
+
[
|
|
74
|
+
'rrm_hostnames_bi',
|
|
75
|
+
`BEFORE INSERT ON hostnames BEGIN
|
|
76
|
+
${append(`SELECT 'h:' || h.hostname FROM hostnames o JOIN hostnames h ON h.scope_id = o.scope_id WHERE o.hostname = NEW.hostname`)} END`,
|
|
77
|
+
],
|
|
78
|
+
['rrm_hostnames_ai', `AFTER INSERT ON hostnames BEGIN ${append(`SELECT 'h:' || NEW.hostname`)} ${hostnamesOfScope('NEW.scope_id')} END`],
|
|
79
|
+
[
|
|
80
|
+
'rrm_hostnames_au',
|
|
81
|
+
`AFTER UPDATE OF hostname, tenant_id, scope_id, vertical_slug, surface, region, status ON hostnames BEGIN
|
|
82
|
+
${append(`SELECT 'h:' || OLD.hostname`)} ${append(`SELECT 'h:' || NEW.hostname`)}
|
|
83
|
+
${hostnamesOfScope('OLD.scope_id')} ${hostnamesOfScope('NEW.scope_id')} END`,
|
|
84
|
+
],
|
|
85
|
+
['rrm_hostnames_ad', `AFTER DELETE ON hostnames BEGIN ${append(`SELECT 'h:' || OLD.hostname`)} ${hostnamesOfScope('OLD.scope_id')} END`],
|
|
86
|
+
['rrm_scopes_ai', `AFTER INSERT ON scopes BEGIN ${hostnamesOfScope('NEW.scope_id')} END`],
|
|
87
|
+
[
|
|
88
|
+
'rrm_scopes_au',
|
|
89
|
+
`AFTER UPDATE OF tenant_id, status, serving_ref, vertical_version_id, vertical, kind, forked_from, jurisdiction ON scopes
|
|
90
|
+
BEGIN ${hostnamesOfScope('NEW.scope_id')} END`,
|
|
91
|
+
],
|
|
92
|
+
['rrm_scopes_ad', `AFTER DELETE ON scopes BEGIN ${hostnamesOfScope('OLD.scope_id')} END`],
|
|
93
|
+
// An insert too: a tenant row replaced whole (a restore, an `INSERT OR REPLACE`) is no UPDATE.
|
|
94
|
+
['rrm_tenants_ai', `AFTER INSERT ON tenants BEGIN ${hostnamesOfTenant('NEW.tenant_id')} END`],
|
|
95
|
+
['rrm_tenants_au', `AFTER UPDATE OF status ON tenants BEGIN ${hostnamesOfTenant('NEW.tenant_id')} END`],
|
|
96
|
+
['rrm_tenants_ad', `AFTER DELETE ON tenants BEGIN ${hostnamesOfTenant('OLD.tenant_id')} END`],
|
|
97
|
+
['rrm_verticals_ai', `AFTER INSERT ON verticals BEGIN ${append(`SELECT 'v:' || NEW.slug`)} END`],
|
|
98
|
+
[
|
|
99
|
+
'rrm_verticals_au',
|
|
100
|
+
`AFTER UPDATE OF slug, serving_ref, serving_version_id ON verticals BEGIN
|
|
101
|
+
${append(`SELECT 'v:' || OLD.slug`)} ${append(`SELECT 'v:' || NEW.slug`)} END`,
|
|
102
|
+
],
|
|
103
|
+
['rrm_verticals_ad', `AFTER DELETE ON verticals BEGIN ${append(`SELECT 'v:' || OLD.slug`)} END`],
|
|
104
|
+
['rrm_versions_ai', `AFTER INSERT ON vertical_versions BEGIN ${dependentsOfVersion('NEW')} END`],
|
|
105
|
+
['rrm_versions_au', `AFTER UPDATE OF id, deployment_ref, manifest_json ON vertical_versions BEGIN ${dependentsOfVersion('OLD')} ${dependentsOfVersion('NEW')} END`],
|
|
106
|
+
['rrm_versions_ad', `AFTER DELETE ON vertical_versions BEGIN ${dependentsOfVersion('OLD')} END`],
|
|
107
|
+
];
|
|
108
|
+
export const ROUTE_READ_MODEL_TRIGGERS = TRIGGERS.map(([name]) => name);
|
|
109
|
+
/** The route read, as the read model stores it: the same joins and gates as `READ_ROUTE_SQL`. */
|
|
110
|
+
const ROUTE_ENTRY_SQL = `SELECT h.tenant_id, h.scope_id, h.vertical_slug, h.surface, h.region, s.jurisdiction,
|
|
111
|
+
s.serving_ref, s.vertical, s.kind, s.forked_from,
|
|
112
|
+
vv.id AS version_id, vv.deployment_ref AS version_ref,
|
|
113
|
+
json_extract(vv.manifest_json, '$.outbound') AS outbound_json,
|
|
114
|
+
json_extract(vv.manifest_json, '$.calls') AS calls_json,
|
|
115
|
+
json_extract(vv.manifest_json, '$.scopeStores') AS scope_stores_json,
|
|
116
|
+
EXISTS (SELECT 1 FROM hostnames INDEXED BY hostnames_scope
|
|
117
|
+
WHERE scope_id = s.scope_id AND status = 'active' AND region IS NOT NULL) AS scope_has_pinned,
|
|
118
|
+
(SELECT json_group_array(sh.hostname) FROM (
|
|
119
|
+
SELECT hostname FROM hostnames INDEXED BY hostnames_scope
|
|
120
|
+
WHERE scope_id = s.scope_id AND status = 'active'
|
|
121
|
+
ORDER BY hostname LIMIT ${ROUTE_SCOPE_HOSTNAMES_MAX}
|
|
122
|
+
) sh) AS scope_hostnames_json
|
|
123
|
+
FROM hostnames h
|
|
124
|
+
JOIN scopes s ON s.scope_id = h.scope_id AND s.tenant_id = h.tenant_id
|
|
125
|
+
JOIN tenants t ON t.tenant_id = s.tenant_id
|
|
126
|
+
LEFT JOIN vertical_versions vv ON vv.id = s.vertical_version_id
|
|
127
|
+
WHERE h.hostname = ? AND h.status = 'active' AND s.status = 'active' AND t.status = 'active'`;
|
|
128
|
+
const SERVING_POLICY_SQL = `SELECT vr.serving_ref,
|
|
129
|
+
json_extract(sv.manifest_json, '$.outbound') AS outbound_json,
|
|
130
|
+
json_extract(sv.manifest_json, '$.calls') AS calls_json,
|
|
131
|
+
json_extract(sv.manifest_json, '$.scopeStores') AS scope_stores_json
|
|
132
|
+
FROM verticals vr LEFT JOIN vertical_versions sv ON sv.id = vr.serving_version_id
|
|
133
|
+
WHERE vr.slug = ?`;
|
|
134
|
+
/** A jurisdiction that pins storage, which KV cannot honour (K-36). `global` pins nothing. */
|
|
135
|
+
const isPinned = (jurisdiction) => jurisdiction !== null && jurisdiction !== 'global';
|
|
136
|
+
/** An active hostname that does not route, and whether its route would be pinned. */
|
|
137
|
+
const REFUSED_ROUTE_SQL = `SELECT h.region, s.jurisdiction FROM hostnames h
|
|
138
|
+
LEFT JOIN scopes s ON s.scope_id = h.scope_id WHERE h.hostname = ? AND h.status = 'active'`;
|
|
139
|
+
export const routeEntryKey = (hostname) => `h:${hostname}`;
|
|
140
|
+
export const servingPolicyEntryKey = (slug) => `v:${slug}`;
|
|
141
|
+
/**
|
|
142
|
+
* A hostname's entry, from its source fields: a route, a refusal, or null for no entry. Null for
|
|
143
|
+
* any residency-pinned name (K-36): KV has no jurisdiction, so the router asks the source. Null too
|
|
144
|
+
* for a route whose scope also holds a pinned hostname, because the route's value lists the scope's
|
|
145
|
+
* hostnames, and no pinned name may appear in any KV value.
|
|
146
|
+
*/
|
|
147
|
+
export function routeEntryOf(f) {
|
|
148
|
+
if (f.region !== null || isPinned(f.jurisdiction))
|
|
149
|
+
return null;
|
|
150
|
+
if (f.routes && f.scopeHasPinnedHostname)
|
|
151
|
+
return null;
|
|
152
|
+
if (!f.routes)
|
|
153
|
+
return f.hostnameActive ? { v: ROUTE_READ_MODEL_VERSION, refused: true } : null;
|
|
154
|
+
const dispatch = f.serving_ref !== null
|
|
155
|
+
? { kind: 'serving', ref: f.serving_ref, vertical: f.vertical }
|
|
156
|
+
: f.version
|
|
157
|
+
? {
|
|
158
|
+
kind: 'version',
|
|
159
|
+
ref: f.version.deployment_ref,
|
|
160
|
+
outbound_json: f.version.outbound_json,
|
|
161
|
+
calls_json: f.version.calls_json,
|
|
162
|
+
scope_stores_json: f.version.scope_stores_json,
|
|
163
|
+
}
|
|
164
|
+
: { kind: 'none' };
|
|
165
|
+
return {
|
|
166
|
+
v: ROUTE_READ_MODEL_VERSION,
|
|
167
|
+
tenant_id: f.tenant_id,
|
|
168
|
+
scope_id: f.scope_id,
|
|
169
|
+
vertical_slug: f.vertical_slug,
|
|
170
|
+
surface: f.surface,
|
|
171
|
+
region: null,
|
|
172
|
+
primary: isPrimaryScopeRow({ kind: f.kind, forked_from: f.forked_from }),
|
|
173
|
+
scope_hostnames: f.scope_hostnames,
|
|
174
|
+
dispatch,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** A vertical's serving policy, from its row and its serving version's manifest fields. */
|
|
178
|
+
export function servingPolicyEntryOf(f) {
|
|
179
|
+
return {
|
|
180
|
+
v: ROUTE_READ_MODEL_VERSION,
|
|
181
|
+
serving_ref: f.serving_ref,
|
|
182
|
+
outbound_json: f.outbound_json,
|
|
183
|
+
calls_json: f.calls_json,
|
|
184
|
+
scope_stores_json: f.scope_stores_json,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** The ledger as a table in the source's own SQLite (`route_read_model_published`). */
|
|
188
|
+
export function sqlPublishedLedger(sql) {
|
|
189
|
+
return {
|
|
190
|
+
digest: (key) => sql.exec('SELECT digest FROM route_read_model_published WHERE key = ?', key).toArray()[0]?.digest,
|
|
191
|
+
set: (key, digest) => {
|
|
192
|
+
sql.exec(`INSERT INTO route_read_model_published (key, digest, at) VALUES (?, ?, ?)
|
|
193
|
+
ON CONFLICT(key) DO UPDATE SET digest = excluded.digest, at = excluded.at`, key, digest, new Date().toISOString());
|
|
194
|
+
},
|
|
195
|
+
delete: (key) => {
|
|
196
|
+
sql.exec('DELETE FROM route_read_model_published WHERE key = ?', key);
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The ledger's mark for a write that was started and not confirmed. It matches no digest, so the
|
|
202
|
+
* key is written again, and it is a ledger entry, so a later "no entry" deletes from KV: an object
|
|
203
|
+
* that stopped between KV accepting a put and the ledger recording it leaves nothing behind.
|
|
204
|
+
*/
|
|
205
|
+
export const UNCERTAIN_DIGEST = 'uncertain';
|
|
206
|
+
/**
|
|
207
|
+
* THE projection writer: put one entry in KV, or delete it, unless the ledger says KV already holds
|
|
208
|
+
* it. The ledger records the write as uncertain before KV is asked and as confirmed only after KV
|
|
209
|
+
* accepted, so neither a refused nor an interrupted write is ever taken for done. Every source
|
|
210
|
+
* writes through this, and nothing else writes the namespace.
|
|
211
|
+
*/
|
|
212
|
+
export async function writeRouteReadModelEntry(to, key, value) {
|
|
213
|
+
const published = to.ledger.digest(key);
|
|
214
|
+
if (value === null) {
|
|
215
|
+
if (published === undefined)
|
|
216
|
+
return 'unchanged';
|
|
217
|
+
await to.kv.delete(kvKeyOf(key));
|
|
218
|
+
to.ledger.delete(key);
|
|
219
|
+
return 'deleted';
|
|
220
|
+
}
|
|
221
|
+
const text = JSON.stringify(value);
|
|
222
|
+
const digest = await digestOf(text);
|
|
223
|
+
if (published === digest)
|
|
224
|
+
return 'unchanged';
|
|
225
|
+
to.ledger.set(key, UNCERTAIN_DIGEST);
|
|
226
|
+
await to.kv.put(kvKeyOf(key), text);
|
|
227
|
+
to.ledger.set(key, digest);
|
|
228
|
+
return 'written';
|
|
229
|
+
}
|
|
230
|
+
/** The comparison the reconcile makes: would the writer change anything for this entry? */
|
|
231
|
+
export async function routeReadModelEntryDiffers(ledger, key, value) {
|
|
232
|
+
const digest = value === null ? undefined : await digestOf(JSON.stringify(value));
|
|
233
|
+
return digest !== ledger.digest(key);
|
|
234
|
+
}
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
// The source as it is today: the one directory's tables.
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
/** What a dirty key publishes now, read from the directory: an entry, or null for no entry. */
|
|
239
|
+
export function computeRouteReadModelEntry(sql, key) {
|
|
240
|
+
if (key.startsWith('h:')) {
|
|
241
|
+
const hostname = key.slice(2);
|
|
242
|
+
const r = sql.exec(ROUTE_ENTRY_SQL, hostname).toArray()[0];
|
|
243
|
+
if (!r) {
|
|
244
|
+
// Not routed: an active name whose scope or tenant is not is a refusal; anything else is none.
|
|
245
|
+
const held = sql.exec(REFUSED_ROUTE_SQL, hostname).toArray()[0];
|
|
246
|
+
if (!held)
|
|
247
|
+
return null;
|
|
248
|
+
return routeEntryOf({
|
|
249
|
+
routes: false, hostnameActive: true, region: held.region, jurisdiction: held.jurisdiction,
|
|
250
|
+
tenant_id: '', scope_id: '', vertical_slug: null, surface: '', serving_ref: null, vertical: null,
|
|
251
|
+
kind: null, forked_from: null, version: null, scope_hostnames: [], scopeHasPinnedHostname: false,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return routeEntryOf({
|
|
255
|
+
routes: true,
|
|
256
|
+
hostnameActive: true,
|
|
257
|
+
tenant_id: r['tenant_id'],
|
|
258
|
+
scope_id: r['scope_id'],
|
|
259
|
+
vertical_slug: r['vertical_slug'],
|
|
260
|
+
surface: r['surface'],
|
|
261
|
+
region: r['region'],
|
|
262
|
+
jurisdiction: r['jurisdiction'],
|
|
263
|
+
serving_ref: r['serving_ref'],
|
|
264
|
+
vertical: r['vertical'],
|
|
265
|
+
kind: r['kind'],
|
|
266
|
+
forked_from: r['forked_from'],
|
|
267
|
+
version: r['version_id'] !== null
|
|
268
|
+
? {
|
|
269
|
+
id: r['version_id'],
|
|
270
|
+
deployment_ref: r['version_ref'],
|
|
271
|
+
outbound_json: r['outbound_json'],
|
|
272
|
+
calls_json: r['calls_json'],
|
|
273
|
+
scope_stores_json: r['scope_stores_json'],
|
|
274
|
+
}
|
|
275
|
+
: null,
|
|
276
|
+
scope_hostnames: JSON.parse(r['scope_hostnames_json']),
|
|
277
|
+
scopeHasPinnedHostname: Number(r['scope_has_pinned']) === 1,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (key.startsWith('v:')) {
|
|
281
|
+
const r = sql.exec(SERVING_POLICY_SQL, key.slice(2)).toArray()[0];
|
|
282
|
+
if (!r)
|
|
283
|
+
return null;
|
|
284
|
+
return servingPolicyEntryOf({
|
|
285
|
+
serving_ref: r['serving_ref'],
|
|
286
|
+
outbound_json: r['outbound_json'],
|
|
287
|
+
calls_json: r['calls_json'],
|
|
288
|
+
scope_stores_json: r['scope_stores_json'],
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
const kvKeyOf = (key) => (key.startsWith('h:') ? routeKvKey(key.slice(2)) : servingPolicyKvKey(key.slice(2)));
|
|
294
|
+
async function digestOf(text) {
|
|
295
|
+
const bytes = new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)));
|
|
296
|
+
return Array.from(bytes.subarray(0, 16), (b) => b.toString(16).padStart(2, '0')).join('');
|
|
297
|
+
}
|
|
298
|
+
const FLUSH_BATCH = 100;
|
|
299
|
+
const FLUSH_CONCURRENCY = 8;
|
|
300
|
+
export class RouteReadModelPublisher {
|
|
301
|
+
sql;
|
|
302
|
+
kv;
|
|
303
|
+
ledger;
|
|
304
|
+
constructor(sql, kv) {
|
|
305
|
+
this.sql = sql;
|
|
306
|
+
this.kv = kv;
|
|
307
|
+
this.ledger = sqlPublishedLedger(sql);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Create the tables and triggers. True when the triggers were not there before: the read model
|
|
311
|
+
* was just switched on (or the directory was just rebuilt), so nothing published can be trusted
|
|
312
|
+
* to match, and the caller marks every key dirty.
|
|
313
|
+
*/
|
|
314
|
+
install() {
|
|
315
|
+
for (const stmt of TABLES_DDL)
|
|
316
|
+
this.sql.exec(stmt);
|
|
317
|
+
const present = new Set(this.sql.exec(`SELECT name FROM sqlite_master WHERE type = 'trigger' AND name GLOB 'rrm_*'`).toArray().map((r) => r.name));
|
|
318
|
+
let fresh = false;
|
|
319
|
+
for (const [name, ddl] of TRIGGERS) {
|
|
320
|
+
if (present.has(name))
|
|
321
|
+
continue;
|
|
322
|
+
this.sql.exec(`CREATE TRIGGER IF NOT EXISTS ${name} ${ddl}`);
|
|
323
|
+
fresh = true;
|
|
324
|
+
}
|
|
325
|
+
return fresh;
|
|
326
|
+
}
|
|
327
|
+
/** Every key the directory could publish, and every key KV may still hold. */
|
|
328
|
+
markAll() {
|
|
329
|
+
this.sql.exec(append(`SELECT 'h:' || hostname FROM hostnames WHERE status = 'active'`));
|
|
330
|
+
this.sql.exec(append(`SELECT 'v:' || slug FROM verticals`));
|
|
331
|
+
this.sql.exec(append(`SELECT key FROM route_read_model_published`));
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The router's miss (`readRoute(…, { publish: true })`): queue the route and its policy, unless
|
|
335
|
+
* they are published already and only KV's propagation is behind — then a queue write per
|
|
336
|
+
* request would buy nothing.
|
|
337
|
+
*/
|
|
338
|
+
requestPublish(hostname) {
|
|
339
|
+
const r = this.sql
|
|
340
|
+
.exec(`SELECT h.region, s.jurisdiction, s.serving_ref, s.vertical,
|
|
341
|
+
EXISTS (SELECT 1 FROM hostnames WHERE scope_id = s.scope_id AND status = 'active' AND region IS NOT NULL) AS mixed
|
|
342
|
+
FROM hostnames h JOIN scopes s ON s.scope_id = h.scope_id WHERE h.hostname = ?`, hostname)
|
|
343
|
+
.toArray()[0];
|
|
344
|
+
// A route never published (K-36: pinned, or naming a pinned sibling): queueing it on every
|
|
345
|
+
// request would buy nothing.
|
|
346
|
+
if (!r || r.region !== null || isPinned(r.jurisdiction) || Number(r.mixed) === 1)
|
|
347
|
+
return;
|
|
348
|
+
const vertical = r.serving_ref !== null ? r.vertical : null;
|
|
349
|
+
const keys = [`h:${hostname}`, ...(vertical ? [`v:${vertical}`] : [])];
|
|
350
|
+
for (const key of keys) {
|
|
351
|
+
const known = this.sql.exec('SELECT 1 FROM route_read_model_published WHERE key = ?', key).toArray().length > 0;
|
|
352
|
+
if (!known)
|
|
353
|
+
this.sql.exec('INSERT INTO route_read_model_outbox (key) VALUES (?)', key);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
pending() {
|
|
357
|
+
return this.sql.exec('SELECT 1 FROM route_read_model_outbox LIMIT 1').toArray().length > 0;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Publish up to `maxKeys` dirty keys. Throws when KV refuses a write, once every write it started
|
|
361
|
+
* has settled: what was published stays published and out of the outbox, the rest is still dirty,
|
|
362
|
+
* and no write of this flush is still in flight to race the next one.
|
|
363
|
+
*
|
|
364
|
+
* `quiet` is asked before each group of keys is read: entries are computed synchronously from the
|
|
365
|
+
* source, and a source whose own call is still in flight may be inside a transaction that has not
|
|
366
|
+
* committed. A flush that meets a busy source stops (`deferred`) and is restarted by the source.
|
|
367
|
+
*/
|
|
368
|
+
async flush(maxKeys = 1_000, quiet = () => true) {
|
|
369
|
+
const out = { written: 0, deleted: 0, unchanged: 0, unreadable: 0, remaining: 0, deferred: false };
|
|
370
|
+
// A key KV refused goes to the back of the outbox and is not tried again in this flush, so one
|
|
371
|
+
// failing key never holds back the changes queued behind it; the caller's retry (the alarm) tries
|
|
372
|
+
// it again. The flush still throws at its end, once every write it started has settled.
|
|
373
|
+
const failed = new Map();
|
|
374
|
+
let done = 0;
|
|
375
|
+
outer: while (done < maxKeys) {
|
|
376
|
+
const batch = this.sql
|
|
377
|
+
.exec(
|
|
378
|
+
// The oldest rows first, THEN grouped: a GROUP BY over the whole outbox would read every row
|
|
379
|
+
// per batch. The limit is a row budget, so a batch may hold fewer keys; later rows of a key
|
|
380
|
+
// stay for a later batch (publishOne deletes only up to the id it read).
|
|
381
|
+
`SELECT key, MAX(id) AS id FROM (SELECT id, key FROM route_read_model_outbox ORDER BY id LIMIT ?)
|
|
382
|
+
GROUP BY key ORDER BY MIN(id)`, Math.min(FLUSH_BATCH, maxKeys - done))
|
|
383
|
+
.toArray();
|
|
384
|
+
const eligible = batch.filter((item) => !failed.has(item.key));
|
|
385
|
+
// Only keys that already failed are left at the front: everything else has been tried.
|
|
386
|
+
if (eligible.length === 0)
|
|
387
|
+
break;
|
|
388
|
+
for (let i = 0; i < eligible.length; i += FLUSH_CONCURRENCY) {
|
|
389
|
+
if (!quiet()) {
|
|
390
|
+
out.deferred = true;
|
|
391
|
+
break outer;
|
|
392
|
+
}
|
|
393
|
+
const group = eligible.slice(i, i + FLUSH_CONCURRENCY);
|
|
394
|
+
const settled = await Promise.allSettled(group.map((item) => this.publishOne(item, out)));
|
|
395
|
+
settled.forEach((r, j) => {
|
|
396
|
+
if (r.status !== 'rejected')
|
|
397
|
+
return;
|
|
398
|
+
const { key, id } = group[j];
|
|
399
|
+
failed.set(key, r.reason);
|
|
400
|
+
// To the back: a fresh row behind everything queued, the rows this attempt read removed.
|
|
401
|
+
this.sql.exec('INSERT INTO route_read_model_outbox (key) VALUES (?)', key);
|
|
402
|
+
this.sql.exec('DELETE FROM route_read_model_outbox WHERE key = ? AND id <= ?', key, id);
|
|
403
|
+
});
|
|
404
|
+
done += group.length;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
out.remaining = Number(this.sql.exec('SELECT COUNT(DISTINCT key) AS n FROM route_read_model_outbox').one().n);
|
|
408
|
+
if (failed.size > 0) {
|
|
409
|
+
const [first] = failed.values();
|
|
410
|
+
throw new Error(`route read model: KV refused ${failed.size} key(s); retried from the alarm. First: ${String(first)}`);
|
|
411
|
+
}
|
|
412
|
+
return out;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* The ledger describes the namespace it was confirmed against, or its confirmations are withdrawn
|
|
416
|
+
* (see `ROUTE_LEDGER_MARKER_KEY`). True when they were, and every key queued to be published again.
|
|
417
|
+
*/
|
|
418
|
+
async verifyNamespace() {
|
|
419
|
+
const stored = this.sql.exec('SELECT after FROM route_read_model_cursor WHERE source = ?', LEDGER_SOURCE).toArray()[0]?.after;
|
|
420
|
+
const marker = await this.kv.get(ROUTE_LEDGER_MARKER_KEY);
|
|
421
|
+
if (stored && marker === stored)
|
|
422
|
+
return false;
|
|
423
|
+
const id = marker ?? crypto.randomUUID();
|
|
424
|
+
if (marker === null)
|
|
425
|
+
await this.kv.put(ROUTE_LEDGER_MARKER_KEY, id);
|
|
426
|
+
// Every confirmation becomes uncertain rather than gone: a present entry is written again, and a
|
|
427
|
+
// key the directory no longer routes is deleted (a no-op in a fresh namespace), so the reset also
|
|
428
|
+
// leaves nothing behind if the namespace was the same one after all.
|
|
429
|
+
this.sql.exec('UPDATE route_read_model_published SET digest = ?', UNCERTAIN_DIGEST);
|
|
430
|
+
this.markAll();
|
|
431
|
+
this.sql.exec(`INSERT INTO route_read_model_cursor (source, after) VALUES (?, ?) ON CONFLICT(source) DO UPDATE SET after = excluded.after`, LEDGER_SOURCE, id);
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
async publishOne({ key, id }, out) {
|
|
435
|
+
let value;
|
|
436
|
+
try {
|
|
437
|
+
value = computeRouteReadModelEntry(this.sql, key);
|
|
438
|
+
}
|
|
439
|
+
catch (err) {
|
|
440
|
+
// A directory row the read cannot parse: the router's own read throws on it too. Absent is
|
|
441
|
+
// the safe entry — the router then asks the directory, as it does today.
|
|
442
|
+
console.error(`route read model: ${key} could not be read; publishing it as absent`, err);
|
|
443
|
+
value = null;
|
|
444
|
+
out.unreadable += 1;
|
|
445
|
+
}
|
|
446
|
+
const outcome = await writeRouteReadModelEntry({ kv: this.kv, ledger: this.ledger }, key, value);
|
|
447
|
+
out[outcome] += 1;
|
|
448
|
+
// Only up to the row this publish read: a change landed meanwhile keeps its own row.
|
|
449
|
+
this.sql.exec('DELETE FROM route_read_model_outbox WHERE key = ? AND id <= ?', key, id);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* One slice of the drift repair, for the scheduled pass: up to `limit` keys from each source
|
|
453
|
+
* (active hostnames, verticals, published keys), resuming where the last pass stopped. A key
|
|
454
|
+
* whose entry differs from what was published is queued. Returns how many were queued.
|
|
455
|
+
*/
|
|
456
|
+
async reconcile(limit = 500) {
|
|
457
|
+
let checked = 0;
|
|
458
|
+
let queued = 0;
|
|
459
|
+
const sources = [
|
|
460
|
+
['h', `SELECT hostname AS k FROM hostnames WHERE hostname > ? ORDER BY hostname LIMIT ?`],
|
|
461
|
+
['v', `SELECT slug AS k FROM verticals WHERE slug > ? ORDER BY slug LIMIT ?`],
|
|
462
|
+
['p', `SELECT key AS k FROM route_read_model_published WHERE key > ? ORDER BY key LIMIT ?`],
|
|
463
|
+
];
|
|
464
|
+
for (const [source, select] of sources) {
|
|
465
|
+
const after = this.sql.exec('SELECT after FROM route_read_model_cursor WHERE source = ?', source).toArray()[0]?.after ?? '';
|
|
466
|
+
const rows = this.sql.exec(select, after, limit).toArray();
|
|
467
|
+
for (const { k } of rows) {
|
|
468
|
+
const key = source === 'p' ? k : `${source}:${k}`;
|
|
469
|
+
checked += 1;
|
|
470
|
+
let value;
|
|
471
|
+
try {
|
|
472
|
+
value = computeRouteReadModelEntry(this.sql, key);
|
|
473
|
+
}
|
|
474
|
+
catch {
|
|
475
|
+
value = null; // the flush publishes an unreadable key as absent, so compare it as that
|
|
476
|
+
}
|
|
477
|
+
if (await routeReadModelEntryDiffers(this.ledger, key, value)) {
|
|
478
|
+
this.sql.exec('INSERT INTO route_read_model_outbox (key) VALUES (?)', key);
|
|
479
|
+
queued += 1;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// A short page is the end of the source: the next pass starts it again from the top.
|
|
483
|
+
const next = rows.length < limit ? '' : rows[rows.length - 1].k;
|
|
484
|
+
this.sql.exec(`INSERT INTO route_read_model_cursor (source, after) VALUES (?, ?) ON CONFLICT(source) DO UPDATE SET after = excluded.after`, source, next);
|
|
485
|
+
}
|
|
486
|
+
return { checked, queued };
|
|
487
|
+
}
|
|
488
|
+
status() {
|
|
489
|
+
const n = (q) => Number(this.sql.exec(q).one().n);
|
|
490
|
+
// The same gates `ROUTE_ENTRY_SQL` / `REFUSED_ROUTE_SQL` and `routeEntryOf` apply, so the dry
|
|
491
|
+
// run's "complete" is what publishing would actually write.
|
|
492
|
+
const unpinned = `h.region IS NULL AND (s.jurisdiction IS NULL OR s.jurisdiction = 'global')`;
|
|
493
|
+
const routes = `EXISTS (SELECT 1 FROM scopes rs JOIN tenants rt ON rt.tenant_id = rs.tenant_id
|
|
494
|
+
WHERE rs.scope_id = h.scope_id AND rs.tenant_id = h.tenant_id
|
|
495
|
+
AND rs.status = 'active' AND rt.status = 'active')`;
|
|
496
|
+
const routable = n(`SELECT COUNT(*) AS n FROM hostnames h JOIN scopes s ON s.scope_id = h.scope_id
|
|
497
|
+
WHERE h.status = 'active' AND ${unpinned} AND ${routes}
|
|
498
|
+
AND NOT EXISTS (SELECT 1 FROM hostnames p WHERE p.scope_id = h.scope_id AND p.status = 'active' AND p.region IS NOT NULL)`);
|
|
499
|
+
const refused = n(`SELECT COUNT(*) AS n FROM hostnames h LEFT JOIN scopes s ON s.scope_id = h.scope_id
|
|
500
|
+
WHERE h.status = 'active' AND ${unpinned} AND NOT ${routes}`);
|
|
501
|
+
return {
|
|
502
|
+
enabled: true,
|
|
503
|
+
outbox: n('SELECT COUNT(DISTINCT key) AS n FROM route_read_model_outbox'),
|
|
504
|
+
published: n('SELECT COUNT(*) AS n FROM route_read_model_published'),
|
|
505
|
+
routable,
|
|
506
|
+
refused,
|
|
507
|
+
pinned: n(`SELECT COUNT(*) AS n FROM hostnames WHERE status = 'active'`) - routable - refused,
|
|
508
|
+
verticals: n('SELECT COUNT(*) AS n FROM verticals'),
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Switch the read model off on a directory that had it: drop the triggers and the outbox, so
|
|
514
|
+
* nothing queues for a binding that is gone. The published ledger stays — it still describes KV,
|
|
515
|
+
* and switching back on marks every key dirty, which reconciles the two.
|
|
516
|
+
*/
|
|
517
|
+
export function uninstallRouteReadModel(sql) {
|
|
518
|
+
for (const name of ROUTE_READ_MODEL_TRIGGERS)
|
|
519
|
+
sql.exec(`DROP TRIGGER IF EXISTS ${name}`);
|
|
520
|
+
const hasOutbox = sql.exec(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'route_read_model_outbox'`).toArray().length > 0;
|
|
521
|
+
if (hasOutbox)
|
|
522
|
+
sql.exec('DELETE FROM route_read_model_outbox');
|
|
523
|
+
}
|
|
524
|
+
//# sourceMappingURL=route-read-model-publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-read-model-publisher.js","sourceRoot":"","sources":["../src/route-read-model-publisher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,kBAAkB,GAInB,MAAM,uBAAuB,CAAC;AAI/B,uFAAuF;AACvF,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,CAAC;AAShE,8FAA8F;AAC9F,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,I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