@substrat-run/adapter-cloudflare 0.217.0 → 0.219.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-lake.d.ts +19 -0
- package/dist/broker-lake.d.ts.map +1 -0
- package/dist/broker-lake.js +20 -0
- package/dist/broker-lake.js.map +1 -0
- package/dist/control-plane-do.d.ts +82 -5
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +276 -25
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +43 -6
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +85 -9
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/delivery-broker-platform.d.ts +52 -0
- package/dist/delivery-broker-platform.d.ts.map +1 -0
- package/dist/delivery-broker-platform.js +77 -0
- package/dist/delivery-broker-platform.js.map +1 -0
- package/dist/delivery-handoff.d.ts +22 -0
- package/dist/delivery-handoff.d.ts.map +1 -1
- package/dist/delivery-handoff.js +19 -0
- package/dist/delivery-handoff.js.map +1 -1
- package/dist/directory-restore-chunks.d.ts +16 -0
- package/dist/directory-restore-chunks.d.ts.map +1 -0
- package/dist/directory-restore-chunks.js +31 -0
- package/dist/directory-restore-chunks.js.map +1 -0
- 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 +5 -4
- package/dist/directory-split-inventory.js.map +1 -1
- package/dist/host.d.ts +7 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +44 -3
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/kick-coalescer-do.d.ts.map +1 -1
- package/dist/kick-coalescer-do.js +5 -4
- package/dist/kick-coalescer-do.js.map +1 -1
- package/dist/scope-do.d.ts +8 -1
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +154 -32
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-wake.d.ts +5 -0
- package/dist/scope-wake.d.ts.map +1 -1
- package/dist/scope-wake.js +2 -1
- package/dist/scope-wake.js.map +1 -1
- package/dist/scope-work.d.ts +1 -1
- package/dist/scope-work.js +1 -1
- package/dist/scope-work.js.map +1 -1
- package/dist/sql.d.ts +2 -2
- package/dist/sql.d.ts.map +1 -1
- package/dist/sql.js +11 -10
- package/dist/sql.js.map +1 -1
- package/dist/supplied-delivery-broker.d.ts +35 -0
- package/dist/supplied-delivery-broker.d.ts.map +1 -0
- package/dist/supplied-delivery-broker.js +55 -0
- package/dist/supplied-delivery-broker.js.map +1 -0
- package/package.json +9 -9
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* Acceptance is idempotent by message id: a handoff repeated after a lost acknowledgement stores
|
|
9
9
|
* nothing twice.
|
|
10
10
|
*
|
|
11
|
-
* Delivery runs from the object's alarm, and only when a receiver is configured.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* (D-79).
|
|
11
|
+
* Delivery runs from the object's alarm, and only when a receiver is configured. A broker with none
|
|
12
|
+
* holds what it accepts, bounded by `BROKER_HELD_RETENTION_MS`, with one alarm to prune it; the one
|
|
13
|
+
* the platform supplies (A5, `delivery-broker-platform.ts`) has the recorder and the live receiver.
|
|
14
|
+
* An object holding nothing arms nothing (D-79).
|
|
15
15
|
*
|
|
16
16
|
* Retries, the pause per receiver, ordering per key and dead letter (A4, #3470) are the kernel's
|
|
17
17
|
* `BrokerStore` over this object's SQLite; the alarm is what runs them. Each receiver is a
|
|
@@ -22,6 +22,18 @@
|
|
|
22
22
|
* attempt, and its state (depth, oldest age, paused receivers, dead letters) whenever that moves
|
|
23
23
|
* (`BrokerTelemetry`, `broker-telemetry.ts`). `state()` answers the same report to a staff read.
|
|
24
24
|
*
|
|
25
|
+
* A5 (#3471): with `shadow`, the broker records every message it is owed under `SHADOW_RECEIVER`
|
|
26
|
+
* (ids, types and times, never a body) and answers `deliveryComparison` from those records and
|
|
27
|
+
* each scope's own witness (`witness`); with `live`, intents handed off live are also owed to that
|
|
28
|
+
* receiver (`LIVE_RECEIVER`). Which receivers a message is owed is the mode its handoff named
|
|
29
|
+
* (`receiversFor`), so a message handed off in shadow is never sent to the real one.
|
|
30
|
+
* `definePlatformDeliveryBrokerDO` (`delivery-broker-platform.ts`) is the hosted wiring of both.
|
|
31
|
+
*
|
|
32
|
+
* #3474: it counts exactly what it receives, delivers, retries, dead-letters, and what a person
|
|
33
|
+
* resends or discards, per UTC day (the kernel's `broker-counts.ts`), and with `SUBSTRAT_BROKER_LAKE`
|
|
34
|
+
* bound it ships those counts to the lake at most every five minutes, from its alarm. `counts()`
|
|
35
|
+
* answers them to a staff read. Unbound, they are kept, bounded, and shipped nowhere.
|
|
36
|
+
*
|
|
25
37
|
* Given a `relay` (#3469), the broker also hands events to other apps' brokers through the router
|
|
26
38
|
* and takes theirs (`acceptRelayed`, which vertical-host's `/internal/broker-relay` door calls), sends
|
|
27
39
|
* requests and pairs their replies: the kernel's `BrokerRelay`, over the same SQLite, registered as
|
|
@@ -30,7 +42,7 @@
|
|
|
30
42
|
* identity is the hosted half still to build.
|
|
31
43
|
*/
|
|
32
44
|
import { DurableObject } from 'cloudflare:workers';
|
|
33
|
-
import { type BrokerStateReport, type BrokerErasure, type BrokerErasureTarget, type BrokerMessage, type BrokerRelayOptions, type BrokerTiming, type DeadLetter, type DeliveryPolicyInput, type DeliveryReceiver, type HandOffAnswer, type HandoffMarks, type RelayHop, type RelayReply, type RelayRequest, type WaitRecord } from '@substrat-run/kernel';
|
|
45
|
+
import { type DeliveryComparison, type HandOffOptions, type WitnessReader, type BrokerStateReport, type BrokerCountDay, type BrokerLakeSink, type BrokerErasure, type BrokerErasureTarget, type BrokerMessage, type BrokerRelayOptions, type BrokerTiming, type DeadLetter, type DeliveryPolicyInput, type DeliveryReceiver, type HandOffAnswer, type HandoffMarks, type RelayHop, type RelayReply, type RelayRequest, type WaitRecord } from '@substrat-run/kernel';
|
|
34
46
|
import { type RelayAnswer, type RelayEnvelope } from '@substrat-run/contracts';
|
|
35
47
|
/** One receiver of the broker, made from the script's env. */
|
|
36
48
|
export interface DeliveryBrokerSubscription<Env> {
|
|
@@ -59,15 +71,40 @@ export interface DeliveryBrokerOptions<Env> {
|
|
|
59
71
|
relay?: (env: Env) => Omit<BrokerRelayOptions, 'now'> & {
|
|
60
72
|
policy?: DeliveryPolicyInput;
|
|
61
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* A5 (#3471): record every message owed under `SHADOW_RECEIVER` (the recorder, which writes one
|
|
76
|
+
* row of ids and times into this object and does nothing else), and answer `deliveryComparison`.
|
|
77
|
+
*/
|
|
78
|
+
shadow?: boolean;
|
|
79
|
+
/** A5: the real receiver for intents handed off live (`LIVE_RECEIVER`), and its policy. */
|
|
80
|
+
live?: {
|
|
81
|
+
receiver: (env: Env) => DeliveryReceiver;
|
|
82
|
+
policy?: DeliveryPolicyInput;
|
|
83
|
+
};
|
|
84
|
+
/** A5: how the comparison reads a scope's own witness of what the drain did. Without it, nothing is compared. */
|
|
85
|
+
witness?: (env: Env) => WitnessReader;
|
|
86
|
+
/**
|
|
87
|
+
* #3474: where the exact counts are shipped. Omitted, the `SUBSTRAT_BROKER_LAKE` Pipelines binding
|
|
88
|
+
* when the script binds one; null, nowhere. A test passes a recorder.
|
|
89
|
+
*/
|
|
90
|
+
lake?: (env: Env) => BrokerLakeSink | null;
|
|
62
91
|
}
|
|
63
92
|
/** The broker as a scope reaches it over RPC. */
|
|
64
93
|
export interface DeliveryBrokerRpc {
|
|
65
|
-
|
|
94
|
+
/** `options` (A5): the mode they were handed off under, and the scope's comparison start. */
|
|
95
|
+
handOff(messages: BrokerMessage[], options?: HandOffOptions): Promise<HandOffAnswer>;
|
|
66
96
|
marks(tenantId: string, scopeId: string): Promise<HandoffMarks>;
|
|
67
97
|
/** #3474: the broker's state now, for staff. Null when telemetry is not bound. */
|
|
68
98
|
state(): Promise<BrokerStateReport | null>;
|
|
69
99
|
/** #3484: a subject's erasure, from the erasing scope's `redactSubject`. */
|
|
70
100
|
eraseSubject(target: BrokerErasureTarget): Promise<BrokerErasure>;
|
|
101
|
+
/** A5 (#3471): the shadow comparison, for staff. Null when this broker records nothing. */
|
|
102
|
+
deliveryComparison(opts?: {
|
|
103
|
+
cursor?: string;
|
|
104
|
+
graceMs?: number;
|
|
105
|
+
}): Promise<DeliveryComparison | null>;
|
|
106
|
+
/** #3474: the exact counts on or after `since` (a UTC day), for staff and billing reads. */
|
|
107
|
+
counts(since?: string): Promise<BrokerCountDay[]>;
|
|
71
108
|
}
|
|
72
109
|
/** The relay's half of the broker, as the receiving door and the app's host code reach it (#3469). */
|
|
73
110
|
export interface DeliveryBrokerRelayRpc {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-broker-do.d.ts","sourceRoot":"","sources":["../src/delivery-broker-do.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"delivery-broker-do.d.ts","sourceRoot":"","sources":["../src/delivery-broker-do.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAA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AAW,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACpG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9D,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChE;AAED,MAAM,MAAM,qBAAqB,CAAC,GAAG,IAAI,KACvC,GAAG,EAAE,kBAAkB,EACvB,GAAG,EAAE,GAAG,KACL,aAAa,CAAC,GAAG,CAAC,GAAG,iBAAiB,GAAG,2BAA2B,GAAG,sBAAsB,GAAG;IAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC;AAEhI,wBAAgB,sBAAsB,CAAC,GAAG,GAAG,OAAO,EAAE,OAAO,GAAE,qBAAqB,CAAC,GAAG,CAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAgN1H"}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* Acceptance is idempotent by message id: a handoff repeated after a lost acknowledgement stores
|
|
9
9
|
* nothing twice.
|
|
10
10
|
*
|
|
11
|
-
* Delivery runs from the object's alarm, and only when a receiver is configured.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* (D-79).
|
|
11
|
+
* Delivery runs from the object's alarm, and only when a receiver is configured. A broker with none
|
|
12
|
+
* holds what it accepts, bounded by `BROKER_HELD_RETENTION_MS`, with one alarm to prune it; the one
|
|
13
|
+
* the platform supplies (A5, `delivery-broker-platform.ts`) has the recorder and the live receiver.
|
|
14
|
+
* An object holding nothing arms nothing (D-79).
|
|
15
15
|
*
|
|
16
16
|
* Retries, the pause per receiver, ordering per key and dead letter (A4, #3470) are the kernel's
|
|
17
17
|
* `BrokerStore` over this object's SQLite; the alarm is what runs them. Each receiver is a
|
|
@@ -22,6 +22,18 @@
|
|
|
22
22
|
* attempt, and its state (depth, oldest age, paused receivers, dead letters) whenever that moves
|
|
23
23
|
* (`BrokerTelemetry`, `broker-telemetry.ts`). `state()` answers the same report to a staff read.
|
|
24
24
|
*
|
|
25
|
+
* A5 (#3471): with `shadow`, the broker records every message it is owed under `SHADOW_RECEIVER`
|
|
26
|
+
* (ids, types and times, never a body) and answers `deliveryComparison` from those records and
|
|
27
|
+
* each scope's own witness (`witness`); with `live`, intents handed off live are also owed to that
|
|
28
|
+
* receiver (`LIVE_RECEIVER`). Which receivers a message is owed is the mode its handoff named
|
|
29
|
+
* (`receiversFor`), so a message handed off in shadow is never sent to the real one.
|
|
30
|
+
* `definePlatformDeliveryBrokerDO` (`delivery-broker-platform.ts`) is the hosted wiring of both.
|
|
31
|
+
*
|
|
32
|
+
* #3474: it counts exactly what it receives, delivers, retries, dead-letters, and what a person
|
|
33
|
+
* resends or discards, per UTC day (the kernel's `broker-counts.ts`), and with `SUBSTRAT_BROKER_LAKE`
|
|
34
|
+
* bound it ships those counts to the lake at most every five minutes, from its alarm. `counts()`
|
|
35
|
+
* answers them to a staff read. Unbound, they are kept, bounded, and shipped nowhere.
|
|
36
|
+
*
|
|
25
37
|
* Given a `relay` (#3469), the broker also hands events to other apps' brokers through the router
|
|
26
38
|
* and takes theirs (`acceptRelayed`, which vertical-host's `/internal/broker-relay` door calls), sends
|
|
27
39
|
* requests and pairs their replies: the kernel's `BrokerRelay`, over the same SQLite, registered as
|
|
@@ -30,8 +42,9 @@
|
|
|
30
42
|
* identity is the hosted half still to build.
|
|
31
43
|
*/
|
|
32
44
|
import { DurableObject } from 'cloudflare:workers';
|
|
33
|
-
import { BrokerRelay, BrokerStore, BrokerTelemetry, RELAY_SUBSCRIPTION, runDeliveryPass, } from '@substrat-run/kernel';
|
|
45
|
+
import { BrokerRelay, BrokerStore, compareDeliveries, LIVE_RECEIVER, SHADOW_RECEIVER, ShadowRecorder, BrokerTelemetry, RELAY_SUBSCRIPTION, runDeliveryPass, BROKER_COUNT_SHIP_MS, } from '@substrat-run/kernel';
|
|
34
46
|
import { analyticsBrokerSink, brokerIdsOf, brokerTelemetryDataset } from './broker-telemetry.js';
|
|
47
|
+
import { brokerLakeStream, pipelineBrokerLakeSink } from './broker-lake.js';
|
|
35
48
|
import { relayEnvelope } from '@substrat-run/contracts';
|
|
36
49
|
export function defineDeliveryBrokerDO(options = {}) {
|
|
37
50
|
const subscriptions = [
|
|
@@ -44,6 +57,14 @@ export function defineDeliveryBrokerDO(options = {}) {
|
|
|
44
57
|
receivers;
|
|
45
58
|
telemetry;
|
|
46
59
|
relay;
|
|
60
|
+
/** A5: the comparison's windows, kept whether or not this broker records, and the recorder when it does. */
|
|
61
|
+
windows;
|
|
62
|
+
recorder;
|
|
63
|
+
witness;
|
|
64
|
+
lake;
|
|
65
|
+
app;
|
|
66
|
+
/** #3474: epoch ms before which no ship is tried again, after one that failed. In memory: a reset retries at once. */
|
|
67
|
+
shipBlockedUntil = 0;
|
|
47
68
|
constructor(ctx, env) {
|
|
48
69
|
super(ctx, env);
|
|
49
70
|
const sql = ctx.storage.sql;
|
|
@@ -55,8 +76,16 @@ export function defineDeliveryBrokerDO(options = {}) {
|
|
|
55
76
|
const relayed = options.relay ? options.relay(env) : null;
|
|
56
77
|
const { policy: relayPolicy, ...relayOptions } = relayed ?? {};
|
|
57
78
|
this.relay = relayed ? new BrokerRelay(brokerSql, { ...relayOptions, now }) : null;
|
|
79
|
+
// A5: the recorder writes into this object's own database, beside the store.
|
|
80
|
+
this.windows = new ShadowRecorder(brokerSql);
|
|
81
|
+
this.recorder = options.shadow ? this.windows : null;
|
|
82
|
+
this.witness = options.shadow && options.witness ? options.witness(env) : null;
|
|
58
83
|
const all = [
|
|
59
84
|
...subscriptions.map((s) => ({ name: s.name, receiver: s.receiver(env), ...(s.policy ? { policy: s.policy } : {}) })),
|
|
85
|
+
...(this.recorder ? [{ name: SHADOW_RECEIVER, receiver: this.recorder.receiver(now) }] : []),
|
|
86
|
+
...(options.live
|
|
87
|
+
? [{ name: LIVE_RECEIVER, receiver: options.live.receiver(env), ...(options.live.policy ? { policy: options.live.policy } : {}) }]
|
|
88
|
+
: []),
|
|
60
89
|
...(this.relay ? [{ name: RELAY_SUBSCRIPTION, receiver: this.relay.receiver(), ...(relayPolicy ? { policy: relayPolicy } : {}) }] : []),
|
|
61
90
|
];
|
|
62
91
|
this.receivers = Object.fromEntries(all.map((s) => [s.name, s.receiver]));
|
|
@@ -69,17 +98,55 @@ export function defineDeliveryBrokerDO(options = {}) {
|
|
|
69
98
|
// #3474: points and state reports, only when the script binds the dataset.
|
|
70
99
|
const dataset = brokerTelemetryDataset(env);
|
|
71
100
|
this.telemetry = dataset ? new BrokerTelemetry(this.store, analyticsBrokerSink(dataset), brokerIdsOf(ctx.id.name)) : null;
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
this.app = brokerIdsOf(ctx.id.name).app;
|
|
102
|
+
if (options.lake) {
|
|
103
|
+
this.lake = options.lake(env);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const stream = brokerLakeStream(env);
|
|
107
|
+
this.lake = stream ? pipelineBrokerLakeSink(stream) : null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async counts(since) {
|
|
111
|
+
return this.store.counts(since);
|
|
112
|
+
}
|
|
113
|
+
/** #3474: ship the counts the lake does not have, when a lake is bound and a ship is due. Never throws. */
|
|
114
|
+
async shipCountsIfDue() {
|
|
115
|
+
if (!this.lake)
|
|
116
|
+
return;
|
|
117
|
+
const at = now();
|
|
118
|
+
const due = this.store.nextCountShipAt();
|
|
119
|
+
if (due === null || due > at || this.shipBlockedUntil > at)
|
|
120
|
+
return;
|
|
121
|
+
try {
|
|
122
|
+
await this.store.shipCounts(this.lake, this.app, at);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
this.shipBlockedUntil = at + BROKER_COUNT_SHIP_MS;
|
|
126
|
+
console.error('substrat: broker counts could not be shipped; the next ship retries them', err);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async handOff(messages, options = {}) {
|
|
74
130
|
// Read before the accept, with no await between: nothing else runs on the object.
|
|
75
131
|
const held = this.telemetry?.heldBefore(messages);
|
|
76
132
|
const at = now();
|
|
77
|
-
|
|
133
|
+
if (options.start)
|
|
134
|
+
this.windows.start(options.start.tenantId, options.start.scopeId, options.start.after, at);
|
|
135
|
+
const answer = this.store.accept(messages, at, options);
|
|
78
136
|
if (held !== undefined)
|
|
79
137
|
this.telemetry.received(messages, held, at);
|
|
80
138
|
await this.armFor();
|
|
81
139
|
return answer;
|
|
82
140
|
}
|
|
141
|
+
async deliveryComparison(opts = {}) {
|
|
142
|
+
if (!this.recorder || !this.witness)
|
|
143
|
+
return null;
|
|
144
|
+
return compareDeliveries(this.recorder, this.witness, brokerIdsOf(this.ctx.id.name), {
|
|
145
|
+
now: now(),
|
|
146
|
+
...(opts.cursor ? { cursor: opts.cursor } : {}),
|
|
147
|
+
...(opts.graceMs !== undefined ? { graceMs: Math.max(0, opts.graceMs) } : {}),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
83
150
|
async state() {
|
|
84
151
|
return this.telemetry?.current(now()) ?? null;
|
|
85
152
|
}
|
|
@@ -121,7 +188,9 @@ export function defineDeliveryBrokerDO(options = {}) {
|
|
|
121
188
|
const pass = await runDeliveryPass(this.store, this.receivers, now, undefined, this.telemetry?.passObserver());
|
|
122
189
|
if (this.relay)
|
|
123
190
|
await this.relay.pass();
|
|
191
|
+
this.recorder?.prune(now());
|
|
124
192
|
this.telemetry?.settle(now());
|
|
193
|
+
await this.shipCountsIfDue();
|
|
125
194
|
await this.armFor();
|
|
126
195
|
return pass;
|
|
127
196
|
}
|
|
@@ -159,7 +228,14 @@ export function defineDeliveryBrokerDO(options = {}) {
|
|
|
159
228
|
* the broker holds nothing.
|
|
160
229
|
*/
|
|
161
230
|
async armFor() {
|
|
162
|
-
|
|
231
|
+
// #3474: a due ship of the counts wakes the broker too, but only with a lake to ship to.
|
|
232
|
+
const ship = this.lake ? this.store.nextCountShipAt() : null;
|
|
233
|
+
const times = [
|
|
234
|
+
this.store.nextWakeAt(),
|
|
235
|
+
this.relay?.nextWakeAt() ?? null,
|
|
236
|
+
this.recorder?.nextWakeAt() ?? null,
|
|
237
|
+
ship === null ? null : Math.max(ship, this.shipBlockedUntil),
|
|
238
|
+
].filter((t) => t !== null);
|
|
163
239
|
const at = times.length ? Math.min(...times) : null;
|
|
164
240
|
if (at === null)
|
|
165
241
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-broker-do.js","sourceRoot":"","sources":["../src/delivery-broker-do.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"delivery-broker-do.js","sourceRoot":"","sources":["../src/delivery-broker-do.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,cAAc,EAId,eAAe,EAEf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GAkBrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAwC,MAAM,yBAAyB,CAAC;AAgF9F,MAAM,UAAU,sBAAsB,CAAgB,OAAO,GAA+B,EAAE;IAC5F,MAAM,aAAa,GAAsC;QACvD,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAA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AAC,UAAU,EAAE;gBACvB,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI;gBAChC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,IAAI;gBACnC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC;aAC7D,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;YACzC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACpD,IAAI,EAAE,KAAK,IAAI;gBAAE,OAAO;YACxB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAClD,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,GAAG,EAAE;gBAAE,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K-74, A5 (#3471): the delivery broker as the platform runs it in a pushed vertical's script.
|
|
3
|
+
*
|
|
4
|
+
* The uploader supplies a class named `PLATFORM_BROKER_CLASS` and binds it as
|
|
5
|
+
* `SUBSTRAT_DELIVERY_BROKER` (`supplied-delivery-broker.ts`, re-exported from the platform's entry),
|
|
6
|
+
* the way it supplies the scope sweeper. That class is a few hundred bytes: it forwards every call
|
|
7
|
+
* to the broker this file defines, which `defineScopeDO` registers under
|
|
8
|
+
* `PLATFORM_DELIVERY_BROKER_KEY` when the vertical's module loads. So the broker is always the one
|
|
9
|
+
* built from the same kernel as the scopes that hand off to it, and a bundle on a kernel from
|
|
10
|
+
* before this registers none: its scopes never hand off either.
|
|
11
|
+
*
|
|
12
|
+
* Wired here, from the script's own env:
|
|
13
|
+
*
|
|
14
|
+
* - the recorder (`shadow`), always: a message handed off in shadow goes nowhere else;
|
|
15
|
+
* - the live receiver for intents (`liveIntentReceiver`): it reads the intent's state from its scope
|
|
16
|
+
* (`intentDeliveryState`, an object in this script's `SCOPE` namespace) and asks the control plane
|
|
17
|
+
* to drain that scope (`/internal/drain-scope` with `broker: true`, the platform secret the upload
|
|
18
|
+
* injects), as the scope's own wake asks; the drain engine runs the intent, as it always has;
|
|
19
|
+
* - the comparison's witness: each scope's own rows (`deliveryWitness`), read at comparison time.
|
|
20
|
+
*/
|
|
21
|
+
import { type BrokerMessage, type DeliveryWitness, type DriveAnswer, type HandoffMarks, type IntentState } from '@substrat-run/kernel';
|
|
22
|
+
import { type DeliveryBrokerDOClass } from './delivery-broker-do.js';
|
|
23
|
+
/** What the platform's broker reads from the script's env. */
|
|
24
|
+
export interface PlatformBrokerEnv {
|
|
25
|
+
/** The vertical's scopes, as its scope host names them (`SCOPE.idFromName(scopeId)`). */
|
|
26
|
+
SCOPE?: DurableObjectNamespace;
|
|
27
|
+
CONTROL_PLANE_URL?: string;
|
|
28
|
+
PLATFORM_SECRET?: string;
|
|
29
|
+
}
|
|
30
|
+
/** The scope's half of A5, over RPC (`ScopeDO.deliveryWitness`, `ScopeDO.intentDeliveryState`). */
|
|
31
|
+
export interface ScopeDeliveryRpc {
|
|
32
|
+
deliveryWitness(after: HandoffMarks, before: string, limit: number): Promise<DeliveryWitness[]>;
|
|
33
|
+
intentDeliveryState(id: string): Promise<IntentState>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Ask the control plane to drain one scope's intents now, as the broker's delivery of one of them.
|
|
37
|
+
* `not-live` when the control plane says the tenant is not live: the intent is the drain's again.
|
|
38
|
+
*/
|
|
39
|
+
export declare function askControlPlaneToDrain(env: PlatformBrokerEnv, m: Pick<BrokerMessage, 'tenantId' | 'scopeId'>): Promise<DriveAnswer>;
|
|
40
|
+
/** The platform's delivery broker class, over this kernel: recorder, live receiver and witness. */
|
|
41
|
+
export declare function definePlatformDeliveryBrokerDO<Env extends PlatformBrokerEnv = PlatformBrokerEnv>(overrides?: {
|
|
42
|
+
settleWaitsMs?: readonly number[];
|
|
43
|
+
drive?: (env: Env, m: BrokerMessage) => Promise<DriveAnswer>;
|
|
44
|
+
}): DeliveryBrokerDOClass<Env>;
|
|
45
|
+
/** What the registry holds: the class, made on first use. */
|
|
46
|
+
export type PlatformBrokerFactory = () => DeliveryBrokerDOClass<PlatformBrokerEnv>;
|
|
47
|
+
/**
|
|
48
|
+
* Register this kernel's broker for the platform's supplied class to forward to. The first
|
|
49
|
+
* registration in an isolate wins: one bundle has one kernel.
|
|
50
|
+
*/
|
|
51
|
+
export declare function registerPlatformDeliveryBroker(): void;
|
|
52
|
+
//# sourceMappingURL=delivery-broker-platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-broker-platform.d.ts","sourceRoot":"","sources":["../src/delivery-broker-platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE7F,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,mGAAmG;AACnG,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAChG,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACvD;AAQD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,iBAAiB,EAAE,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAezI;AAED,mGAAmG;AACnG,wBAAgB,8BAA8B,CAAC,GAAG,SAAS,iBAAiB,GAAG,iBAAiB,EAC9F,SAAS,GAAE;IAAE,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;CAAO,GAClH,qBAAqB,CAAC,GAAG,CAAC,CAa5B;AAED,6DAA6D;AAC7D,MAAM,MAAM,qBAAqB,GAAG,MAAM,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;AAEnF;;;GAGG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CAMrD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K-74, A5 (#3471): the delivery broker as the platform runs it in a pushed vertical's script.
|
|
3
|
+
*
|
|
4
|
+
* The uploader supplies a class named `PLATFORM_BROKER_CLASS` and binds it as
|
|
5
|
+
* `SUBSTRAT_DELIVERY_BROKER` (`supplied-delivery-broker.ts`, re-exported from the platform's entry),
|
|
6
|
+
* the way it supplies the scope sweeper. That class is a few hundred bytes: it forwards every call
|
|
7
|
+
* to the broker this file defines, which `defineScopeDO` registers under
|
|
8
|
+
* `PLATFORM_DELIVERY_BROKER_KEY` when the vertical's module loads. So the broker is always the one
|
|
9
|
+
* built from the same kernel as the scopes that hand off to it, and a bundle on a kernel from
|
|
10
|
+
* before this registers none: its scopes never hand off either.
|
|
11
|
+
*
|
|
12
|
+
* Wired here, from the script's own env:
|
|
13
|
+
*
|
|
14
|
+
* - the recorder (`shadow`), always: a message handed off in shadow goes nowhere else;
|
|
15
|
+
* - the live receiver for intents (`liveIntentReceiver`): it reads the intent's state from its scope
|
|
16
|
+
* (`intentDeliveryState`, an object in this script's `SCOPE` namespace) and asks the control plane
|
|
17
|
+
* to drain that scope (`/internal/drain-scope` with `broker: true`, the platform secret the upload
|
|
18
|
+
* injects), as the scope's own wake asks; the drain engine runs the intent, as it always has;
|
|
19
|
+
* - the comparison's witness: each scope's own rows (`deliveryWitness`), read at comparison time.
|
|
20
|
+
*/
|
|
21
|
+
import { DeliveryFailure, liveIntentReceiver, } from '@substrat-run/kernel';
|
|
22
|
+
import { PLATFORM_DELIVERY_BROKER_KEY } from '@substrat-run/contracts';
|
|
23
|
+
import { PLATFORM_SECRET_HEADER } from '@substrat-run/contracts/wire-headers';
|
|
24
|
+
import { defineDeliveryBrokerDO } from './delivery-broker-do.js';
|
|
25
|
+
function scopeOf(env, scopeId) {
|
|
26
|
+
const ns = env.SCOPE;
|
|
27
|
+
if (!ns)
|
|
28
|
+
throw new Error('the platform delivery broker reaches scopes through the SCOPE namespace, and this script binds none');
|
|
29
|
+
return ns.get(ns.idFromName(scopeId));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ask the control plane to drain one scope's intents now, as the broker's delivery of one of them.
|
|
33
|
+
* `not-live` when the control plane says the tenant is not live: the intent is the drain's again.
|
|
34
|
+
*/
|
|
35
|
+
export async function askControlPlaneToDrain(env, m) {
|
|
36
|
+
if (!env.CONTROL_PLANE_URL || !env.PLATFORM_SECRET) {
|
|
37
|
+
throw new DeliveryFailure('this script has no control plane to ask (CONTROL_PLANE_URL, PLATFORM_SECRET)', { status: 503 });
|
|
38
|
+
}
|
|
39
|
+
const res = await fetch(new URL('/internal/drain-scope', env.CONTROL_PLANE_URL), {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: { 'content-type': 'application/json', [PLATFORM_SECRET_HEADER]: env.PLATFORM_SECRET },
|
|
42
|
+
body: JSON.stringify({ tenantId: m.tenantId, scopeId: m.scopeId, platformRequests: true, events: false, broker: true }),
|
|
43
|
+
});
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
await res.body?.cancel();
|
|
46
|
+
throw new DeliveryFailure(`the control plane answered ${res.status} to the broker's drain`, { status: res.status });
|
|
47
|
+
}
|
|
48
|
+
const answer = (await res.json().catch(() => ({})));
|
|
49
|
+
return answer.broker === 'declined' ? 'not-live' : 'driven';
|
|
50
|
+
}
|
|
51
|
+
/** The platform's delivery broker class, over this kernel: recorder, live receiver and witness. */
|
|
52
|
+
export function definePlatformDeliveryBrokerDO(overrides = {}) {
|
|
53
|
+
return defineDeliveryBrokerDO({
|
|
54
|
+
shadow: true,
|
|
55
|
+
live: {
|
|
56
|
+
receiver: (env) => liveIntentReceiver({
|
|
57
|
+
state: (m) => scopeOf(env, m.scopeId).intentDeliveryState(m.id),
|
|
58
|
+
drive: (m) => (overrides.drive ? overrides.drive(env, m) : askControlPlaneToDrain(env, m)),
|
|
59
|
+
...(overrides.settleWaitsMs ? { settleWaitsMs: overrides.settleWaitsMs } : {}),
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
witness: (env) => (scope, before, limit) => scopeOf(env, scope.scopeId).deliveryWitness(scope.start, before, limit),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Register this kernel's broker for the platform's supplied class to forward to. The first
|
|
67
|
+
* registration in an isolate wins: one bundle has one kernel.
|
|
68
|
+
*/
|
|
69
|
+
export function registerPlatformDeliveryBroker() {
|
|
70
|
+
const slot = globalThis;
|
|
71
|
+
const key = Symbol.for(PLATFORM_DELIVERY_BROKER_KEY);
|
|
72
|
+
if (slot[key])
|
|
73
|
+
return;
|
|
74
|
+
let made;
|
|
75
|
+
slot[key] = () => (made ??= definePlatformDeliveryBrokerDO());
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=delivery-broker-platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-broker-platform.js","sourceRoot":"","sources":["../src/delivery-broker-platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,eAAe,EACf,kBAAkB,GAOnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAA8B,MAAM,yBAAyB,CAAC;AAgB7F,SAAS,OAAO,CAAC,GAAsB,EAAE,OAAe;IACtD,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IACrB,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,qGAAqG,CAAC,CAAC;IAChI,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAgC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,GAAsB,EAAE,CAA8C;IACjH,IAAI,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QACnD,MAAM,IAAI,eAAe,CAAC,8EAA8E,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7H,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,iBAAiB,CAAC,EAAE;QAC/E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,sBAAsB,CAAC,EAAE,GAAG,CAAC,eAAe,EAAE;QAC9F,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,C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AAC,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/E,CAAC;SACL;QACD,OAAO,EAAE,CAAC,GAAG,EAAiB,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;KACnI,CAAC,CAAC;AACL,CAAC;AAKD;;;GAGG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,IAAI,GAAG,UAA0E,CAAC;IACxF,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IACrD,IAAI,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO;IACtB,IAAI,IAA0D,CAAC;IAC/D,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,KAAK,8BAA8B,EAAE,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -43,4 +43,26 @@ export declare function handoffDue(state: HandoffState | null, now: number): boo
|
|
|
43
43
|
* backwards, and no marks are invented where neither side has any.
|
|
44
44
|
*/
|
|
45
45
|
export declare function mergeHandoff(fresh: HandoffState | null, next: HandoffState): HandoffState;
|
|
46
|
+
/**
|
|
47
|
+
* A5 (#3471): the delivery mode the control plane last told this scope (`wake.broker` on its
|
|
48
|
+
* wake's answer), in storage KV under its own key, so a mode change never races the marks a handoff
|
|
49
|
+
* merges. Absent: off, and nothing is handed off.
|
|
50
|
+
*/
|
|
51
|
+
export declare const DELIVERY_MODE_KEY = "delivery-mode";
|
|
52
|
+
export interface DeliveryModeState {
|
|
53
|
+
mode: 'shadow' | 'live';
|
|
54
|
+
/** The marks the handoff was seeded at when the mode went on: the comparison window's start. */
|
|
55
|
+
start: HandoffMarks;
|
|
56
|
+
/** The broker has not yet acknowledged a handoff carrying `start`. */
|
|
57
|
+
startPending?: true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The mode state after the control plane answered `mode`. Off clears it. Going on from off seeds:
|
|
61
|
+
* the handoff starts at what the scope holds now (`seed`), so nothing committed while it was off is
|
|
62
|
+
* handed off, and a new comparison window starts there. Shadow ⇄ live keeps the window.
|
|
63
|
+
*/
|
|
64
|
+
export declare function deliveryModeAfter(prior: DeliveryModeState | null, mode: 'off' | 'shadow' | 'live', seed: () => HandoffMarks): {
|
|
65
|
+
next: DeliveryModeState | null;
|
|
66
|
+
seeded: HandoffMarks | null;
|
|
67
|
+
};
|
|
46
68
|
//# sourceMappingURL=delivery-handoff.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-handoff.d.ts","sourceRoot":"","sources":["../src/delivery-handoff.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEvF,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,mGAAmG;IACnG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,4FAA4F;AAC5F,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,GAAG,IAAI,EAC1B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,GAAG,EAAE,MAAM,EACX,GAAG,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC1C,YAAY,CAWd;AAED,qFAAqF;AACrF,eAAO,MAAM,cAAc,KAAK,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
|
package/dist/delivery-handoff.js
CHANGED
|
@@ -58,4 +58,23 @@ export function mergeHandoff(fresh, next) {
|
|
|
58
58
|
const { marks: _drop, ...rest } = next;
|
|
59
59
|
return fresh?.marks || next.marks ? { ...rest, marks } : rest;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* A5 (#3471): the delivery mode the control plane last told this scope (`wake.broker` on its
|
|
63
|
+
* wake's answer), in storage KV under its own key, so a mode change never races the marks a handoff
|
|
64
|
+
* merges. Absent: off, and nothing is handed off.
|
|
65
|
+
*/
|
|
66
|
+
export const DELIVERY_MODE_KEY = 'delivery-mode';
|
|
67
|
+
/**
|
|
68
|
+
* The mode state after the control plane answered `mode`. Off clears it. Going on from off seeds:
|
|
69
|
+
* the handoff starts at what the scope holds now (`seed`), so nothing committed while it was off is
|
|
70
|
+
* handed off, and a new comparison window starts there. Shadow ⇄ live keeps the window.
|
|
71
|
+
*/
|
|
72
|
+
export function deliveryModeAfter(prior, mode, seed) {
|
|
73
|
+
if (mode === 'off')
|
|
74
|
+
return { next: null, seeded: null };
|
|
75
|
+
if (prior)
|
|
76
|
+
return { next: prior.mode === mode ? prior : { ...prior, mode }, seeded: null };
|
|
77
|
+
const start = seed();
|
|
78
|
+
return { next: { mode, start, startPending: true }, seeded: start };
|
|
79
|
+
}
|
|
61
80
|
//# sourceMappingURL=delivery-handoff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-handoff.js","sourceRoot":"","sources":["../src/delivery-handoff.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAqB,MAAM,sBAAsB,CAAC;AAEvF,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAcvD,4FAA4F;AAC5F,MAAM,UAAU,mBAAmB,CACjC,KAA0B,EAC1B,KAA+B,EAC/B,GAAW,EACX,GAA2C;IAE3C,MAAM,OAAO,GAAG,CAAC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AAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAUjD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA+B,EAC/B,IAA+B,EAC/B,IAAwB;IAExB,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACxD,IAAI,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC3F,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;IACrB,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pieces a paged directory restore stages one RPC each (#3494).
|
|
3
|
+
*
|
|
4
|
+
* A stored copy's pages are about `SCOPE_DUMP_PAGE_MAX_BYTES` of cells by construction (#2868),
|
|
5
|
+
* but a copy written before pages existed is one page holding the whole directory, and a page
|
|
6
|
+
* may be read from a store that sized its pages differently. So every page is cut again here: no
|
|
7
|
+
* piece carries more than `RESTORE_CHUNK_MAX_BYTES` of cells by `rowBytes`' estimate (which is over,
|
|
8
|
+
* never under), well inside the 32 MiB an RPC carries. A single row larger than that travels
|
|
9
|
+
* alone, as the export pages it. A table may span pieces; each piece keeps the table's DDL and
|
|
10
|
+
* columns, which is what the stage holds every later piece of it to.
|
|
11
|
+
*/
|
|
12
|
+
import type { ScopeDumpTable } from '@substrat-run/contracts';
|
|
13
|
+
/** The most cells, by `rowBytes`' estimate, one staged piece carries. */
|
|
14
|
+
export declare const RESTORE_CHUNK_MAX_BYTES: number;
|
|
15
|
+
export declare function restoreChunksOf(page: readonly ScopeDumpTable[], maxBytes?: number): ScopeDumpTable[][];
|
|
16
|
+
//# sourceMappingURL=directory-restore-chunks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-restore-chunks.d.ts","sourceRoot":"","sources":["../src/directory-restore-chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AAEvD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,EAAE,QAAQ,SAA0B,GAAG,cAAc,EAAE,EAAE,CAyBvH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { rowBytes } from './scope-do.js';
|
|
2
|
+
/** The most cells, by `rowBytes`' estimate, one staged piece carries. */
|
|
3
|
+
export const RESTORE_CHUNK_MAX_BYTES = 8 * 1024 * 1024;
|
|
4
|
+
export function restoreChunksOf(page, maxBytes = RESTORE_CHUNK_MAX_BYTES) {
|
|
5
|
+
const chunks = [];
|
|
6
|
+
let current = [];
|
|
7
|
+
let bytes = 0;
|
|
8
|
+
const flush = () => {
|
|
9
|
+
if (current.length > 0)
|
|
10
|
+
chunks.push(current);
|
|
11
|
+
current = [];
|
|
12
|
+
bytes = 0;
|
|
13
|
+
};
|
|
14
|
+
for (const table of page) {
|
|
15
|
+
let fragment = { ...table, rows: [] };
|
|
16
|
+
current.push(fragment);
|
|
17
|
+
for (const row of table.rows) {
|
|
18
|
+
const size = rowBytes(row);
|
|
19
|
+
if (bytes > 0 && bytes + size > maxBytes) {
|
|
20
|
+
flush();
|
|
21
|
+
fragment = { ...table, rows: [] };
|
|
22
|
+
current.push(fragment);
|
|
23
|
+
}
|
|
24
|
+
fragment.rows.push(row);
|
|
25
|
+
bytes += size;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
flush();
|
|
29
|
+
return chunks;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=directory-restore-chunks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-restore-chunks.js","sourceRoot":"","sources":["../src/directory-restore-chunks.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,yEAAyE;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvD,MAAM,UAAU,eAAe,CAAC,IAA+B,EAAE,QAAQ,GAAG,uBAAuB;IACjG,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,IAAI,OAAO,GAAqB,EAAE,CAAC;IACnC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,GAAG,EAAE,CAAC;QACb,KAAK,GAAG,CAAC,CAAC;IACZ,CAAC,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,IAAI,QAAQ,GAAmB,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,GAAG,QAAQ,EAAE,CAAC;gBACzC,KAAK,EAAE,CAAC;gBACR,QAAQ,GAAG,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzB,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,KAAK,IAAI,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -33,8 +33,8 @@ export interface SiteRow {
|
|
|
33
33
|
note?: string;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* `transactionSync` and `storage.transaction` sites:
|
|
37
|
-
* model's two, #3395,
|
|
36
|
+
* `transactionSync` and `storage.transaction` sites: 53 in code (the rfc's 48, plus the routing read
|
|
37
|
+
* model's two, #3395, the dual-write's one, step 3b, and the paged restore's stage, #3494).
|
|
38
38
|
*/
|
|
39
39
|
export declare const DIRECTORY_TRANSACTION_SITES: readonly SiteRow[];
|
|
40
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-split-inventory.d.ts","sourceRoot":"","sources":["../src/directory-split-inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAClF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAiBD;;;GAGG;AACH,eAAO,MAA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