@substrat-run/adapter-cloudflare 0.234.0 → 0.236.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/broker-facet-seam.d.ts +126 -0
- package/dist/broker-facet-seam.d.ts.map +1 -0
- package/dist/broker-facet-seam.js +66 -0
- package/dist/broker-facet-seam.js.map +1 -0
- package/dist/control-plane-do.d.ts +13 -10
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +42 -25
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +27 -1
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +111 -12
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/delivery-broker-facet.d.ts +46 -0
- package/dist/delivery-broker-facet.d.ts.map +1 -0
- package/dist/delivery-broker-facet.js +71 -0
- package/dist/delivery-broker-facet.js.map +1 -0
- package/dist/delivery-broker-supervisor-do.d.ts +88 -0
- package/dist/delivery-broker-supervisor-do.d.ts.map +1 -0
- package/dist/delivery-broker-supervisor-do.js +380 -0
- package/dist/delivery-broker-supervisor-do.js.map +1 -0
- package/dist/directory-cutover.d.ts +3 -3
- package/dist/directory-cutover.d.ts.map +1 -1
- package/dist/directory-cutover.js +13 -1
- package/dist/directory-cutover.js.map +1 -1
- package/dist/directory-split-inventory.js +1 -1
- package/dist/directory-split-inventory.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +104 -26
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-facets.d.ts +43 -0
- package/dist/scope-facets.d.ts.map +1 -1
- package/dist/scope-facets.js +2 -20
- package/dist/scope-facets.js.map +1 -1
- package/dist/scope-supervisor-do.d.ts +28 -5
- package/dist/scope-supervisor-do.d.ts.map +1 -1
- package/dist/scope-supervisor-do.js +122 -9
- package/dist/scope-supervisor-do.js.map +1 -1
- package/dist/supplied-delivery-broker.d.ts +1 -0
- package/dist/supplied-delivery-broker.d.ts.map +1 -1
- package/dist/supplied-delivery-broker.js +1 -0
- package/dist/supplied-delivery-broker.js.map +1 -1
- package/dist/tenant-due-coverage.d.ts +71 -0
- package/dist/tenant-due-coverage.d.ts.map +1 -0
- package/dist/tenant-due-coverage.js +92 -0
- package/dist/tenant-due-coverage.js.map +1 -0
- package/dist/tenant-due-evidence.d.ts +105 -0
- package/dist/tenant-due-evidence.d.ts.map +1 -0
- package/dist/tenant-due-evidence.js +164 -0
- package/dist/tenant-due-evidence.js.map +1 -0
- package/dist/tenant-due-index-do.d.ts +25 -2
- package/dist/tenant-due-index-do.d.ts.map +1 -1
- package/dist/tenant-due-index-do.js +22 -2
- package/dist/tenant-due-index-do.js.map +1 -1
- package/dist/tenant-due-nudge.d.ts +3 -2
- package/dist/tenant-due-nudge.d.ts.map +1 -1
- package/dist/tenant-due-nudge.js.map +1 -1
- package/dist/tenant-due-work-do.d.ts +14 -0
- package/dist/tenant-due-work-do.d.ts.map +1 -1
- package/dist/tenant-due-work-do.js +10 -1
- package/dist/tenant-due-work-do.js.map +1 -1
- package/package.json +12 -12
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track B (broker RFC §6.2, #3466): the delivery broker's supervisor — the class a script would
|
|
3
|
+
* execute for its brokers when a broker runs as a facet. Platform code only. Switched: nothing on
|
|
4
|
+
* `main` exports it from a deployed script, and the uploader supplies the broker as an object, so
|
|
5
|
+
* every broker still runs as it did (`docs/architecture/scope-facets.md` §8).
|
|
6
|
+
*
|
|
7
|
+
* One object per broker, `brokerName(tenant, app, environment)`, as today, in two layers:
|
|
8
|
+
*
|
|
9
|
+
* - **This supervisor** receives every call, holds the alarm, holds the platform's bindings (the
|
|
10
|
+
* `SCOPE` namespace, the control plane's origin, the platform secret), and keeps one table of its
|
|
11
|
+
* own, `_substrat_supervisor`, in the object's storage: the rollback fence's marker, the wake the
|
|
12
|
+
* facet asked for, and the scopes whose handoffs it carried. Its SQL names that table literally.
|
|
13
|
+
* - **The facet** holds the broker: the kernel's `BrokerStore` over a SQLite database of its own,
|
|
14
|
+
* its retries, pauses, lanes and dead letter. Its code arrives inert (`code`, the
|
|
15
|
+
* `defineDeliveryBrokerFacet` class bundled as text), and is loaded through the Worker Loader with
|
|
16
|
+
* `globalOutbound: null` and an empty env.
|
|
17
|
+
*
|
|
18
|
+
* **The pins** come from the object's own name, which the platform chose when it addressed the
|
|
19
|
+
* broker (`idFromName(brokerName(…))`), never from the facet. An object with no name, or named for
|
|
20
|
+
* another app than this script's, refuses every call. The isolate id is the whole name under the
|
|
21
|
+
* release, so two tenants, two apps or two environments never share an isolate, and the name can be
|
|
22
|
+
* compiled into the facet's entry as a constant: the loader caches an isolate's code under its id.
|
|
23
|
+
*
|
|
24
|
+
* **The alarm** is armed before every call into the facet but a read (`BROKER_READ_METHODS`) and `sync()`ed, as the scope supervisor's
|
|
25
|
+
* is (`spikes/scope-facet-wakeups`): a message the facet accepts lives in the facet's database and
|
|
26
|
+
* the alarm in this object's, so no single commit holds both, and the pre-arm is what keeps an
|
|
27
|
+
* accepted message from ever being left without a wake. After the call, the facet's answer carries
|
|
28
|
+
* the broker's next wake, read from its store, and the alarm moves to it once no call is in flight.
|
|
29
|
+
* A call that fails leaves a wake `prearmMs` out; the alarm arms again before it forwards, so a pass
|
|
30
|
+
* that dies halfway runs again from this alarm.
|
|
31
|
+
*
|
|
32
|
+
* **What reaches out** goes through a handle made per call (`BrokerPlatformHandle`): a scope read, a
|
|
33
|
+
* witness, a drain or a lake ship. Each is pinned to this broker's tenant, and a scope is reachable
|
|
34
|
+
* only once a handoff from it has passed through this supervisor (`#admit`), so a facet can never
|
|
35
|
+
* read a scope of another tenant that shares the app's `SCOPE` namespace.
|
|
36
|
+
*/
|
|
37
|
+
import { DurableObject, RpcTarget } from 'cloudflare:workers';
|
|
38
|
+
import { brokerIdsOf, DeliveryFailure, } from '@substrat-run/kernel';
|
|
39
|
+
import { BROKER_FACET, BROKER_FACET_CLASS, BROKER_READ_METHODS, BROKER_SCOPE_READS, BrokerFacetFenced, brokerRpcMethods, holdsBrokerData, } from './broker-facet-seam.js';
|
|
40
|
+
import { askControlPlaneToDrain, askControlPlaneToShip } from './delivery-broker-platform.js';
|
|
41
|
+
import { servedBySupervisor } from './scope-facets.js';
|
|
42
|
+
/** See `DeliveryBrokerSupervisorOptions.prearmMs`. */
|
|
43
|
+
export const DEFAULT_BROKER_PREARM_MS = 30_000;
|
|
44
|
+
/** The generated module the supervisor puts in front of the bundle, so the env stays empty. */
|
|
45
|
+
const FACET_ENTRY_MODULE = 'substrat-broker-facet.js';
|
|
46
|
+
/** The marker table's keys; a vouched scope is `scope:<id>`. */
|
|
47
|
+
const KEY_SERVED_SINCE = 'served_since';
|
|
48
|
+
const KEY_WANT_AT = 'want_at';
|
|
49
|
+
const SCOPE_KEY = 'scope:';
|
|
50
|
+
/**
|
|
51
|
+
* The module the facet is loaded through: the bundle's class, constructed with the broker's name as a
|
|
52
|
+
* constant compiled into code, so the Worker Loader's env stays `{}` and no binding or secret reaches
|
|
53
|
+
* the facet. The name is safe as a constant because the isolate id carries all of it. Exported for
|
|
54
|
+
* the test that reads it.
|
|
55
|
+
*/
|
|
56
|
+
export function brokerFacetEntrySource(mainModule, className, constants) {
|
|
57
|
+
return [
|
|
58
|
+
`import * as bundle from ${JSON.stringify(`./${mainModule}`)};`,
|
|
59
|
+
`const constants = Object.freeze(${JSON.stringify(constants)});`,
|
|
60
|
+
`const Facet = bundle[${JSON.stringify(className)}];`,
|
|
61
|
+
`if (typeof Facet !== 'function') throw new Error(${JSON.stringify(`broker bundle: no export '${className}'`)});`,
|
|
62
|
+
`export class ${BROKER_FACET_CLASS} extends Facet {`,
|
|
63
|
+
` constructor(ctx, env) { super(ctx, { ...constants }); }`,
|
|
64
|
+
`}`,
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
/** A delivery failure as plain values, since its detail does not survive the RPC hop (`BrokerAsk`). */
|
|
68
|
+
function askFailed(err) {
|
|
69
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
70
|
+
if (!(err instanceof DeliveryFailure))
|
|
71
|
+
return { ok: false, message };
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
message,
|
|
75
|
+
...(err.status !== undefined ? { status: err.status } : {}),
|
|
76
|
+
...(err.retryAfterMs !== undefined ? { retryAfterMs: err.retryAfterMs } : {}),
|
|
77
|
+
...(err.permanent !== undefined ? { permanent: err.permanent } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* What a broker facet may ask its supervisor for during one call (`BrokerPlatformHandle`). Built per
|
|
82
|
+
* call and passed with it. Every request is pinned to this broker's tenant and to a scope whose
|
|
83
|
+
* handoff passed through this supervisor; the secret and the bindings are read here and never handed on.
|
|
84
|
+
*/
|
|
85
|
+
class BrokerPlatform extends RpcTarget {
|
|
86
|
+
#pins;
|
|
87
|
+
#env;
|
|
88
|
+
#vouched;
|
|
89
|
+
constructor(pins, env, vouched) {
|
|
90
|
+
super();
|
|
91
|
+
this.#pins = pins;
|
|
92
|
+
this.#env = env;
|
|
93
|
+
this.#vouched = vouched;
|
|
94
|
+
}
|
|
95
|
+
#scope(what, scopeId) {
|
|
96
|
+
if (typeof scopeId !== 'string' || !this.#vouched(scopeId)) {
|
|
97
|
+
throw new Error(`broker supervisor: ${what} refused: no handoff from that scope has reached this broker`);
|
|
98
|
+
}
|
|
99
|
+
const ns = this.#env.SCOPE;
|
|
100
|
+
if (!ns)
|
|
101
|
+
throw new Error(`broker supervisor: ${what} refused: no scope namespace is bound`);
|
|
102
|
+
return ns.get(ns.idFromName(scopeId));
|
|
103
|
+
}
|
|
104
|
+
#message(what, m) {
|
|
105
|
+
if (m?.tenantId !== this.#pins.tenantId)
|
|
106
|
+
throw new Error(`broker supervisor: ${what} refused: it names another tenant than this broker's`);
|
|
107
|
+
this.#scope(what, m.scopeId);
|
|
108
|
+
return { tenantId: this.#pins.tenantId, scopeId: m.scopeId };
|
|
109
|
+
}
|
|
110
|
+
async scopeState(scopeId, read, id) {
|
|
111
|
+
if (!BROKER_SCOPE_READS.includes(read)) {
|
|
112
|
+
throw new Error(`broker supervisor: a scope read refused: '${String(read)}' is not a broker's`);
|
|
113
|
+
}
|
|
114
|
+
return this.#scope('a scope read', scopeId)[read](id);
|
|
115
|
+
}
|
|
116
|
+
async witness(scopeId, after, before, limit, since) {
|
|
117
|
+
return this.#scope('a witness read', scopeId).deliveryWitness(after, before, limit, ...(since === undefined ? [] : [since]));
|
|
118
|
+
}
|
|
119
|
+
async drain(message) {
|
|
120
|
+
const m = this.#message('a drain ask', message);
|
|
121
|
+
try {
|
|
122
|
+
return { ok: true, value: await askControlPlaneToDrain(this.#env, m) };
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
return askFailed(err);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async ship(message) {
|
|
129
|
+
const m = this.#message('a lake ship', message);
|
|
130
|
+
try {
|
|
131
|
+
return { ok: true, value: await askControlPlaneToShip(this.#env, m) };
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
return askFailed(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const FORWARD = Symbol('broker supervisor forward');
|
|
139
|
+
export function defineDeliveryBrokerSupervisorDO(options) {
|
|
140
|
+
const prearmMs = options.prearmMs ?? DEFAULT_BROKER_PREARM_MS;
|
|
141
|
+
if (!(prearmMs > 0))
|
|
142
|
+
throw new Error('broker supervisor: prearmMs must be positive');
|
|
143
|
+
// The platform's own surface, whatever a bundle adds: no app code is read to decide it.
|
|
144
|
+
const forwarded = new Set([...brokerRpcMethods(), ...(options.forward ?? [])]);
|
|
145
|
+
class DeliveryBrokerSupervisor extends DurableObject {
|
|
146
|
+
/** Calls into the facet that have armed and not yet settled: the pre-arm is theirs while > 0. */
|
|
147
|
+
#inflight = 0;
|
|
148
|
+
/** Why this object refuses every call (a fence, or a name it cannot serve), or null. */
|
|
149
|
+
#fenced;
|
|
150
|
+
#pins;
|
|
151
|
+
constructor(ctx, env) {
|
|
152
|
+
super(ctx, env);
|
|
153
|
+
const storage = ctx.storage;
|
|
154
|
+
const named = ctx.id.name;
|
|
155
|
+
const ids = brokerIdsOf(named);
|
|
156
|
+
const app = env.SUBSTRAT_VERTICAL ?? options.app;
|
|
157
|
+
// Before anything is written: a name this supervisor cannot pin, or an existing broker's rows.
|
|
158
|
+
if (named === undefined || ids.tenantId === '' || ids.app === '') {
|
|
159
|
+
this.#pins = null;
|
|
160
|
+
this.#fenced = 'broker supervisor: this object has no broker name (tenant/app[@environment]) to pin its facet to';
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (ids.app !== app) {
|
|
164
|
+
this.#pins = null;
|
|
165
|
+
this.#fenced = `broker supervisor: this object is named for app '${ids.app}', and this script serves '${app}'`;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.#pins = { name: named, tenantId: ids.tenantId, app: ids.app, ...(ids.environment ? { environment: ids.environment } : {}) };
|
|
169
|
+
if (!servedBySupervisor(storage) && holdsBrokerData(storage)) {
|
|
170
|
+
this.#fenced =
|
|
171
|
+
'BrokerFacetFenced: this broker holds messages in its own object storage (it ran before brokers ' +
|
|
172
|
+
'became facets). The broker supervisor serves new brokers only, and moving a broker into a facet ' +
|
|
173
|
+
'is not built: serve this script with the broker class as an object';
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.#fenced = null;
|
|
177
|
+
// The rollback fence's marker, before any call can reach the facet (`assertBrokerNotSupervised`).
|
|
178
|
+
storage.sql.exec(`CREATE TABLE IF NOT EXISTS _substrat_supervisor (key TEXT PRIMARY KEY, value TEXT NOT NULL)`);
|
|
179
|
+
storage.sql.exec(`INSERT OR IGNORE INTO _substrat_supervisor (key, value) VALUES (?, ?)`, KEY_SERVED_SINCE, new Date().toISOString());
|
|
180
|
+
}
|
|
181
|
+
// -- the supervisor's own table ---------------------------------------------------------
|
|
182
|
+
#read(key) {
|
|
183
|
+
const row = this.ctx.storage.sql
|
|
184
|
+
.exec(`SELECT value FROM _substrat_supervisor WHERE key = ?`, key)
|
|
185
|
+
.toArray()[0];
|
|
186
|
+
return row?.value ?? null;
|
|
187
|
+
}
|
|
188
|
+
#write(key, value) {
|
|
189
|
+
if (value === null)
|
|
190
|
+
this.ctx.storage.sql.exec(`DELETE FROM _substrat_supervisor WHERE key = ?`, key);
|
|
191
|
+
else
|
|
192
|
+
this.ctx.storage.sql.exec(`INSERT OR REPLACE INTO _substrat_supervisor (key, value) VALUES (?, ?)`, key, value);
|
|
193
|
+
}
|
|
194
|
+
#wantAt() {
|
|
195
|
+
const v = this.#read(KEY_WANT_AT);
|
|
196
|
+
return v === null ? null : Number(v);
|
|
197
|
+
}
|
|
198
|
+
#want(at) {
|
|
199
|
+
const current = this.#wantAt();
|
|
200
|
+
if (current === null || at < current)
|
|
201
|
+
this.#write(KEY_WANT_AT, String(at));
|
|
202
|
+
}
|
|
203
|
+
/** Has a handoff from this scope passed through here? What the handle reaches a scope by. */
|
|
204
|
+
#vouched(scopeId) {
|
|
205
|
+
return this.#read(SCOPE_KEY + scopeId) !== null;
|
|
206
|
+
}
|
|
207
|
+
// -- the pins ---------------------------------------------------------------------------
|
|
208
|
+
#refuseIfFenced() {
|
|
209
|
+
if (this.#fenced !== null || this.#pins === null)
|
|
210
|
+
throw new BrokerFacetFenced(this.#fenced ?? 'broker supervisor: unpinned');
|
|
211
|
+
return this.#pins;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* What a call names, checked before it reaches the facet: every tenant a scope's call names is
|
|
215
|
+
* this broker's, and each scope a handoff names is recorded as one this broker may reach.
|
|
216
|
+
*/
|
|
217
|
+
#admit(pins, method, args) {
|
|
218
|
+
const refuse = (what) => {
|
|
219
|
+
throw new Error(`broker supervisor: '${method}' refused: it names ${what} than this broker's`);
|
|
220
|
+
};
|
|
221
|
+
if (method === 'handOff') {
|
|
222
|
+
const messages = Array.isArray(args[0]) ? args[0] : [];
|
|
223
|
+
const start = args[1]?.start;
|
|
224
|
+
const scopes = new Set();
|
|
225
|
+
for (const m of [...messages, ...(start ? [start] : [])]) {
|
|
226
|
+
if (m?.tenantId !== pins.tenantId)
|
|
227
|
+
refuse('another tenant');
|
|
228
|
+
if (typeof m.scopeId !== 'string' || m.scopeId === '')
|
|
229
|
+
refuse('no scope');
|
|
230
|
+
scopes.add(m.scopeId);
|
|
231
|
+
}
|
|
232
|
+
for (const scopeId of scopes) {
|
|
233
|
+
this.ctx.storage.sql.exec(`INSERT OR IGNORE INTO _substrat_supervisor (key, value) VALUES (?, ?)`, SCOPE_KEY + scopeId, pins.tenantId);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else if (method === 'marks') {
|
|
237
|
+
if (args[0] !== pins.tenantId)
|
|
238
|
+
refuse('another tenant');
|
|
239
|
+
}
|
|
240
|
+
else if (method === 'eraseSubject') {
|
|
241
|
+
if (args[0]?.tenantId !== pins.tenantId)
|
|
242
|
+
refuse('another tenant');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// -- the facet --------------------------------------------------------------------------
|
|
246
|
+
#facet(pins) {
|
|
247
|
+
const release = this.env.SUBSTRAT_VERSION_ID ?? 'unversioned';
|
|
248
|
+
const id = `${release}:broker:${pins.name}`;
|
|
249
|
+
return this.ctx.facets.get(BROKER_FACET, () => {
|
|
250
|
+
const worker = this.env.SCOPE_LOADER.get(id, () => this.#code(pins));
|
|
251
|
+
return { class: worker.getDurableObjectClass(BROKER_FACET_CLASS) };
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
#code(pins) {
|
|
255
|
+
const code = typeof options.code === 'function' ? options.code(this.env) : options.code;
|
|
256
|
+
if (FACET_ENTRY_MODULE in code.modules)
|
|
257
|
+
throw new Error(`broker bundle: '${FACET_ENTRY_MODULE}' is the supervisor's`);
|
|
258
|
+
return {
|
|
259
|
+
compatibilityDate: code.compatibilityDate,
|
|
260
|
+
...(code.compatibilityFlags ? { compatibilityFlags: [...code.compatibilityFlags] } : {}),
|
|
261
|
+
mainModule: FACET_ENTRY_MODULE,
|
|
262
|
+
modules: {
|
|
263
|
+
...code.modules,
|
|
264
|
+
[FACET_ENTRY_MODULE]: brokerFacetEntrySource(code.mainModule, code.className ?? BROKER_FACET_CLASS, {
|
|
265
|
+
SUBSTRAT_BROKER_NAME: pins.name,
|
|
266
|
+
}),
|
|
267
|
+
},
|
|
268
|
+
env: {},
|
|
269
|
+
globalOutbound: null,
|
|
270
|
+
...(options.limits ? { limits: { ...options.limits } } : {}),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
#handle(pins) {
|
|
274
|
+
return new BrokerPlatform(pins, this.env, (scopeId) => this.#vouched(scopeId));
|
|
275
|
+
}
|
|
276
|
+
// -- the alarm --------------------------------------------------------------------------
|
|
277
|
+
/** Arm no later than `prearmMs` from now, and wait until that is durable. */
|
|
278
|
+
async #preArm() {
|
|
279
|
+
const at = Date.now() + prearmMs;
|
|
280
|
+
const current = await this.ctx.storage.getAlarm();
|
|
281
|
+
if (current === null || current > at)
|
|
282
|
+
await this.ctx.storage.setAlarm(at);
|
|
283
|
+
await this.ctx.storage.sync();
|
|
284
|
+
}
|
|
285
|
+
/** What a settled call tells the supervisor: the broker's next wake, or that the call failed. */
|
|
286
|
+
#note(reply) {
|
|
287
|
+
if (reply === undefined)
|
|
288
|
+
this.#want(Date.now() + prearmMs);
|
|
289
|
+
else if (reply.wakeAt !== null)
|
|
290
|
+
this.#want(reply.wakeAt);
|
|
291
|
+
}
|
|
292
|
+
/** Move the alarm to the wake wanted; while a call is in flight, only ever earlier. */
|
|
293
|
+
async #settleAlarm() {
|
|
294
|
+
const target = this.#wantAt();
|
|
295
|
+
const current = await this.ctx.storage.getAlarm();
|
|
296
|
+
if (this.#inflight > 0) {
|
|
297
|
+
if (target !== null && (current === null || target < current))
|
|
298
|
+
await this.ctx.storage.setAlarm(target);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (target === null) {
|
|
302
|
+
if (current !== null)
|
|
303
|
+
await this.ctx.storage.deleteAlarm();
|
|
304
|
+
}
|
|
305
|
+
else if (current !== target) {
|
|
306
|
+
await this.ctx.storage.setAlarm(target);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/** One call into the facet, under the pre-arm. */
|
|
310
|
+
async [FORWARD](method, args) {
|
|
311
|
+
const pins = this.#refuseIfFenced();
|
|
312
|
+
if (!forwarded.has(method))
|
|
313
|
+
throw new Error(`broker supervisor: '${method}' is not forwarded`);
|
|
314
|
+
this.#admit(pins, method, args);
|
|
315
|
+
// A read accepts and moves nothing, so it needs no wake of its own: no pre-arm, no settle.
|
|
316
|
+
if (BROKER_READ_METHODS.has(method))
|
|
317
|
+
return (await this.#facet(pins).supervisedCall(method, args, this.#handle(pins))).value;
|
|
318
|
+
this.#inflight += 1;
|
|
319
|
+
let reply;
|
|
320
|
+
try {
|
|
321
|
+
await this.#preArm();
|
|
322
|
+
reply = await this.#facet(pins).supervisedCall(method, args, this.#handle(pins));
|
|
323
|
+
return reply.value;
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
this.#inflight -= 1;
|
|
327
|
+
try {
|
|
328
|
+
this.#note(reply);
|
|
329
|
+
await this.#settleAlarm();
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
// The pre-arm stands, so a failure here costs an early alarm, never a lost one.
|
|
333
|
+
console.error('substrat: broker supervisor could not settle its alarm', err);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async alarm() {
|
|
338
|
+
if (this.#fenced !== null || this.#pins === null)
|
|
339
|
+
return;
|
|
340
|
+
const pins = this.#pins;
|
|
341
|
+
this.#inflight += 1;
|
|
342
|
+
let reply;
|
|
343
|
+
try {
|
|
344
|
+
// Arm again first, so this pass is covered whatever happens below.
|
|
345
|
+
await this.#preArm();
|
|
346
|
+
const want = this.#wantAt();
|
|
347
|
+
if (want !== null && want <= Date.now())
|
|
348
|
+
this.#write(KEY_WANT_AT, null);
|
|
349
|
+
reply = await this.#facet(pins).supervisedCall('alarm', [], this.#handle(pins));
|
|
350
|
+
}
|
|
351
|
+
catch (err) {
|
|
352
|
+
console.error('substrat: broker facet alarm failed; armed again', err);
|
|
353
|
+
}
|
|
354
|
+
finally {
|
|
355
|
+
this.#inflight -= 1;
|
|
356
|
+
try {
|
|
357
|
+
this.#note(reply);
|
|
358
|
+
await this.#settleAlarm();
|
|
359
|
+
}
|
|
360
|
+
catch (err) {
|
|
361
|
+
console.error('substrat: broker supervisor could not settle its alarm', err);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
// The broker's RPC surface, each method a call into the facet under the pre-arm.
|
|
367
|
+
for (const name of forwarded) {
|
|
368
|
+
if (Object.prototype.hasOwnProperty.call(DeliveryBrokerSupervisor.prototype, name))
|
|
369
|
+
continue;
|
|
370
|
+
Object.defineProperty(DeliveryBrokerSupervisor.prototype, name, {
|
|
371
|
+
value: function (...args) {
|
|
372
|
+
return this[FORWARD](name, args);
|
|
373
|
+
},
|
|
374
|
+
writable: true,
|
|
375
|
+
configurable: true,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
return DeliveryBrokerSupervisor;
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=delivery-broker-supervisor-do.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-broker-supervisor-do.js","sourceRoot":"","sources":["../src/delivery-broker-supervisor-do.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAA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,SAAS,EAAE,IAAI,CAAC;YAAE,SAAS;QAC7F,MAAM,CAAC,cAAc,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,EAAE;YAC9D,KAAK,EAAE,UAA0C,GAAG,IAAe;gBACjE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -240,9 +240,9 @@ export declare function tenantCutoverParityOf(tenantId: string, known: boolean,
|
|
|
240
240
|
* - `verified`: the comparison found nothing and compared every frozen table;
|
|
241
241
|
* - `differs`: it found differences in the tenant's rows or read-model entries;
|
|
242
242
|
* - `incomplete`: it found nothing, but some frozen tables are not shown compared (`uncompared`).
|
|
243
|
-
* Either its run started before the mirror switched them on
|
|
244
|
-
*
|
|
245
|
-
* finished in an earlier run). Incomplete too when it stopped on an error, a range was truncated, or
|
|
243
|
+
* Either its run started before the mirror switched them on (the gate refuses such a flip since
|
|
244
|
+
* #3842, so a tenant flipped before then may still show it), or no row keeps the tables it compared
|
|
245
|
+
* (it finished in an earlier run). Incomplete too when it stopped on an error, a range was truncated, or
|
|
246
246
|
* it had changes in flight (keys set aside unjudged, or read-model entries not compared);
|
|
247
247
|
* - `none`: no comparison of the tenant has finished, or the comparison is off.
|
|
248
248
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-cutover.d.ts","sourceRoot":"","sources":["../src/directory-cutover.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"directory-cutover.d.ts","sourceRoot":"","sources":["../src/directory-cutover.ts"],"names":[],"mappings":"AAkGA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAsE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAu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C,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,aAAa,CAgBvF;CACF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,aAAa,GAAG,IAAI,EAC5B,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,YAAY,GAAG,QAAQ,CAAC,GAC9D,gBAAgB,GAAG,IAAI,CAqBzB"}
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
* **The gate, in code** (`refusal`, in the same transaction as the flag's write): the switch is on;
|
|
55
55
|
* 3b's dual-write is on for every table a tenant object holds; 3d's comparison is on and its last
|
|
56
56
|
* finished comparison of this tenant verified, with nothing in flight, nothing truncated, after the
|
|
57
|
-
* last table was switched on
|
|
57
|
+
* last table was switched on, within `verifyMaxAgeMs`, and its receipt (`DirectoryVerify.receiptOf`)
|
|
58
|
+
* shows every table the flip freezes in (`CUTOVER_TABLES`) compared; 3c's backfill filled it if it ran; the
|
|
58
59
|
* tenant is `active`; nothing for it is queued in the dual-write's outbox or its claim work; and the
|
|
59
60
|
* object holds nothing parked (asked just before).
|
|
60
61
|
*
|
|
@@ -498,6 +499,17 @@ export class DirectoryCutover {
|
|
|
498
499
|
const lastSince = [...since.values()].sort().at(-1) ?? '';
|
|
499
500
|
if (report.checkedAt < lastSince)
|
|
500
501
|
return 'the last comparison is older than a table the dual-write copies';
|
|
502
|
+
// Finishing after every switch-on is not having read every table: a run fixes its tables when it
|
|
503
|
+
// starts (`DirectoryVerify.ensureRun`), so a table switched on while it walked is not compared in
|
|
504
|
+
// it, even for a tenant it reaches later. The flip freezes in every CUTOVER_TABLES entry, so the
|
|
505
|
+
// comparison judged must show each of them read (#3842).
|
|
506
|
+
const receipt = verify.receiptOf(owner);
|
|
507
|
+
if (!receipt?.tables)
|
|
508
|
+
return 'the last comparison of this tenant finished in an earlier run, and no row keeps the tables it compared; compare again';
|
|
509
|
+
const read = new Set(receipt.tables);
|
|
510
|
+
const uncompared = CUTOVER_TABLES.filter((t) => !read.has(t));
|
|
511
|
+
if (uncompared.length > 0)
|
|
512
|
+
return `the last comparison of this tenant did not compare ${uncompared.join(', ')}; compare again`;
|
|
501
513
|
if (Date.parse(report.checkedAt) < this.now() - (this.options.verifyMaxAgeMs ?? 24 * 60 * 60 * 1000))
|
|
502
514
|
return 'the last comparison is too old; compare again';
|
|
503
515
|
if (this.sql.exec(`SELECT 1 FROM directory_mirror_outbox WHERE target = ? LIMIT 1`, owner).toArray().length > 0) {
|