@substrat-run/adapter-cloudflare 0.215.0 → 0.217.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-telemetry.d.ts +20 -0
- package/dist/broker-telemetry.d.ts.map +1 -0
- package/dist/broker-telemetry.js +29 -0
- package/dist/broker-telemetry.js.map +1 -0
- package/dist/connection-sweep-do.d.ts +83 -0
- package/dist/connection-sweep-do.d.ts.map +1 -0
- package/dist/connection-sweep-do.js +89 -0
- package/dist/connection-sweep-do.js.map +1 -0
- package/dist/control-plane-do.d.ts +54 -43
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +131 -80
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +94 -0
- package/dist/delivery-broker-do.d.ts.map +1 -0
- package/dist/delivery-broker-do.js +172 -0
- package/dist/delivery-broker-do.js.map +1 -0
- package/dist/delivery-handoff.d.ts +46 -0
- package/dist/delivery-handoff.d.ts.map +1 -0
- package/dist/delivery-handoff.js +61 -0
- package/dist/delivery-handoff.js.map +1 -0
- package/dist/directory-mirror-apply.d.ts +59 -0
- package/dist/directory-mirror-apply.d.ts.map +1 -0
- package/dist/directory-mirror-apply.js +158 -0
- package/dist/directory-mirror-apply.js.map +1 -0
- package/dist/directory-mirror-claims.d.ts +77 -0
- package/dist/directory-mirror-claims.d.ts.map +1 -0
- package/dist/directory-mirror-claims.js +129 -0
- package/dist/directory-mirror-claims.js.map +1 -0
- package/dist/directory-mirror.d.ts +201 -0
- package/dist/directory-mirror.d.ts.map +1 -0
- package/dist/directory-mirror.js +557 -0
- package/dist/directory-mirror.js.map +1 -0
- package/dist/directory-objects.d.ts +24 -0
- package/dist/directory-objects.d.ts.map +1 -1
- package/dist/directory-objects.js +125 -1
- package/dist/directory-objects.js.map +1 -1
- package/dist/directory-placement.d.ts +17 -0
- package/dist/directory-placement.d.ts.map +1 -1
- package/dist/directory-placement.js +28 -2
- package/dist/directory-placement.js.map +1 -1
- package/dist/directory-split-inventory.d.ts +4 -1
- package/dist/directory-split-inventory.d.ts.map +1 -1
- package/dist/directory-split-inventory.js +7 -1
- package/dist/directory-split-inventory.js.map +1 -1
- package/dist/host.d.ts +11 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +44 -5
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/peer-call-target.d.ts +61 -0
- package/dist/peer-call-target.d.ts.map +1 -0
- package/dist/peer-call-target.js +98 -0
- package/dist/peer-call-target.js.map +1 -0
- package/dist/reconcile-on-wake.d.ts.map +1 -1
- package/dist/reconcile-on-wake.js +5 -3
- package/dist/reconcile-on-wake.js.map +1 -1
- package/dist/route-read-model-publisher.d.ts +29 -4
- package/dist/route-read-model-publisher.d.ts.map +1 -1
- package/dist/route-read-model-publisher.js +137 -3
- package/dist/route-read-model-publisher.js.map +1 -1
- package/dist/route-read-model.d.ts +75 -1
- package/dist/route-read-model.d.ts.map +1 -1
- package/dist/route-read-model.js +118 -0
- package/dist/route-read-model.js.map +1 -1
- package/dist/route-resolver.d.ts +33 -5
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +130 -70
- package/dist/route-resolver.js.map +1 -1
- package/dist/scope-do.d.ts +11 -0
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +292 -21
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-sweeper-do.d.ts +12 -2
- package/dist/scope-sweeper-do.d.ts.map +1 -1
- package/dist/scope-sweeper-do.js.map +1 -1
- package/dist/scope-work.d.ts +1 -1
- package/dist/scope-work.d.ts.map +1 -1
- package/dist/scope-work.js +1 -0
- package/dist/scope-work.js.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3474 on the Durable Object: the kernel's broker telemetry (`BrokerTelemetry`, `reportHandoff`)
|
|
3
|
+
* written into an Analytics Engine dataset, bound as `SUBSTRAT_BROKER_TELEMETRY` on the app's script
|
|
4
|
+
* — the same script that binds the broker, so the scope's handoff and the broker's own steps land
|
|
5
|
+
* together. Unbound, nothing is written: the broker and the scopes run unobserved.
|
|
6
|
+
*
|
|
7
|
+
* `writeDataPoint` is buffered by the runtime and never awaited; a throw drops the point.
|
|
8
|
+
*/
|
|
9
|
+
import { type BrokerTelemetrySink } from '@substrat-run/kernel';
|
|
10
|
+
import type { AnalyticsEngineDatasetLike } from './connector-calls.js';
|
|
11
|
+
/** The dataset an env binds for broker telemetry, or null. Read structurally: the env is the app's. */
|
|
12
|
+
export declare function brokerTelemetryDataset(env: unknown): AnalyticsEngineDatasetLike | null;
|
|
13
|
+
/** A sink writing every point and state report into `dataset`, in `BROKER_DATA_POINT_LAYOUT`. */
|
|
14
|
+
export declare function analyticsBrokerSink(dataset: AnalyticsEngineDatasetLike): BrokerTelemetrySink;
|
|
15
|
+
/** The broker object's (tenant, app) from its name, `brokerName(tenantId, app)`. */
|
|
16
|
+
export declare function brokerIdsOf(name: string | undefined): {
|
|
17
|
+
tenantId: string;
|
|
18
|
+
app: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=broker-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broker-telemetry.d.ts","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAA6C,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,uGAAuG;AACvG,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,0BAA0B,GAAG,IAAI,CAKtF;AAED,iGAAiG;AACjG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,mBAAmB,CAK5F;AAED,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAGvF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3474 on the Durable Object: the kernel's broker telemetry (`BrokerTelemetry`, `reportHandoff`)
|
|
3
|
+
* written into an Analytics Engine dataset, bound as `SUBSTRAT_BROKER_TELEMETRY` on the app's script
|
|
4
|
+
* — the same script that binds the broker, so the scope's handoff and the broker's own steps land
|
|
5
|
+
* together. Unbound, nothing is written: the broker and the scopes run unobserved.
|
|
6
|
+
*
|
|
7
|
+
* `writeDataPoint` is buffered by the runtime and never awaited; a throw drops the point.
|
|
8
|
+
*/
|
|
9
|
+
import { BROKER_TELEMETRY_BINDING, brokerDataPoint } from '@substrat-run/kernel';
|
|
10
|
+
/** The dataset an env binds for broker telemetry, or null. Read structurally: the env is the app's. */
|
|
11
|
+
export function brokerTelemetryDataset(env) {
|
|
12
|
+
const ds = env?.[BROKER_TELEMETRY_BINDING];
|
|
13
|
+
return ds && typeof ds.writeDataPoint === 'function'
|
|
14
|
+
? ds
|
|
15
|
+
: null;
|
|
16
|
+
}
|
|
17
|
+
/** A sink writing every point and state report into `dataset`, in `BROKER_DATA_POINT_LAYOUT`. */
|
|
18
|
+
export function analyticsBrokerSink(dataset) {
|
|
19
|
+
return {
|
|
20
|
+
point: (p) => dataset.writeDataPoint(brokerDataPoint(p)),
|
|
21
|
+
state: (s) => dataset.writeDataPoint(brokerDataPoint(s)),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The broker object's (tenant, app) from its name, `brokerName(tenantId, app)`. */
|
|
25
|
+
export function brokerIdsOf(name) {
|
|
26
|
+
const at = name?.indexOf('/') ?? -1;
|
|
27
|
+
return at > 0 ? { tenantId: name.slice(0, at), app: name.slice(at + 1) } : { tenantId: name ?? '', app: '' };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=broker-telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broker-telemetry.js","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAA4B,MAAM,sBAAsB,CAAC;AAG3G,uGAAuG;AACvG,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,MAAM,EAAE,GAAI,GAAkD,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAC3F,OAAO,EAAE,IAAI,OAAQ,EAAiC,CAAC,cAAc,KAAK,UAAU;QAClF,CAAC,CAAE,EAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACxD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,IAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
2
|
+
/**
|
|
3
|
+
* K-69 (no scheduled walk over tenants), step 4.2 (rfc/tenant-scale.md §7.4, §8.8, §12; #3376): a
|
|
4
|
+
* connection's connector sweep driven by that connection's own alarm, rather than by a phase of the
|
|
5
|
+
* `*\/15` pass that walks every connection.
|
|
6
|
+
*
|
|
7
|
+
* One object per connection (`connectionSweepName`). It holds the connection's address and its
|
|
8
|
+
* alarm, nothing else: no credential, no authority, no data. Each alarm runs the deployment's sweep
|
|
9
|
+
* for the one connection (`run`, closed over at code time like `defineKickCoalescerDO`'s), and then
|
|
10
|
+
* arms the next: at the connection's interval from the end of this run, or at the time the sweep
|
|
11
|
+
* itself said is worth another try (a crash back-off's end, a provider's poll interval). Its sweep is
|
|
12
|
+
* the pass's own, so the attempt rows, the crash back-off, the per-connection budget, the landings
|
|
13
|
+
* and the operator's pause (#3324) all hold unchanged. What changes is that one connection's sweep is
|
|
14
|
+
* its own invocation: a slow or failing one holds no other connection behind it.
|
|
15
|
+
*
|
|
16
|
+
* Nothing is kept at rest (D-79): an object whose connection is revoked or gone clears its storage
|
|
17
|
+
* and arms nothing, and so does one whose deployment has handed the sweep back to the pass (`owned`
|
|
18
|
+
* false). A handed-back object is woken again only by `ensure`.
|
|
19
|
+
*/
|
|
20
|
+
/** Which connection an object sweeps: what the deployment needs to read it back. */
|
|
21
|
+
export interface ConnectionSweepRef {
|
|
22
|
+
id: string;
|
|
23
|
+
tenantId: string;
|
|
24
|
+
vertical: string;
|
|
25
|
+
provider: string;
|
|
26
|
+
}
|
|
27
|
+
/** What one run of a connection's sweep said, so the object knows when to run again. */
|
|
28
|
+
export interface ConnectionSweepRun {
|
|
29
|
+
/** The connection is revoked or no longer exists: clear, and arm nothing. */
|
|
30
|
+
gone?: boolean;
|
|
31
|
+
/** Epoch ms: the sweep waited the connection out (back-off, poll interval) until then. */
|
|
32
|
+
notBefore?: number;
|
|
33
|
+
/** This connection's interval between runs, ms. Absent, the object's default. */
|
|
34
|
+
intervalMs?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What the pass's check found for one connection (`ensure`):
|
|
38
|
+
* - `held`: armed, on time. The connection's own alarm has it.
|
|
39
|
+
* - `started`: nothing was armed, so the check armed it. The first time for a connection, or one the
|
|
40
|
+
* pass handed over this pass; on any later pass, an alarm that was lost.
|
|
41
|
+
* - `overdue`: armed for a time more than `overdueAfterMs` gone, so the check armed it for now.
|
|
42
|
+
*/
|
|
43
|
+
export type ConnectionSweepCheck = 'held' | 'started' | 'overdue';
|
|
44
|
+
/** The RPC surface a `defineConnectionSweepDO` class exposes over its stub. */
|
|
45
|
+
export interface ConnectionSweepDo {
|
|
46
|
+
ensure(connection: ConnectionSweepRef): Promise<ConnectionSweepCheck>;
|
|
47
|
+
}
|
|
48
|
+
/** The one object per connection: `ns.get(ns.idFromName(connectionSweepName(connectionId)))`. */
|
|
49
|
+
export declare function connectionSweepName(connectionId: string): string;
|
|
50
|
+
/** A connection's default interval between runs: the pass's cadence, as each connection had. */
|
|
51
|
+
export declare const CONNECTION_SWEEP_INTERVAL_MS: number;
|
|
52
|
+
/** How far past its time an armed alarm may be before the check calls it overdue: K-69's hour. */
|
|
53
|
+
export declare const CONNECTION_SWEEP_OVERDUE_MS: number;
|
|
54
|
+
/**
|
|
55
|
+
* The window a connection's first run is spread over, by its id. Handing every connection over in one
|
|
56
|
+
* pass would otherwise start every sweep in the same second.
|
|
57
|
+
*/
|
|
58
|
+
export declare const CONNECTION_SWEEP_FIRST_SPREAD_MS: number;
|
|
59
|
+
/** A stable spread of `[0, spreadMs)` by a connection's id. */
|
|
60
|
+
export declare function spreadOf(connectionId: string, spreadMs: number): number;
|
|
61
|
+
export interface ConnectionSweepConfig<Env> {
|
|
62
|
+
/**
|
|
63
|
+
* Whether this deployment's connections are swept by their own objects. Read on every alarm, so
|
|
64
|
+
* handing the sweep back to the pass needs no call to each object: each clears on its next wake.
|
|
65
|
+
*/
|
|
66
|
+
owned(env: Env): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* One run of one connection's sweep. CODE-TIME, as `defineKickCoalescerDO`'s `run`: the authority
|
|
69
|
+
* is the deployment's, so this object decides only WHEN. A throw is logged and the next run armed
|
|
70
|
+
* at the interval; it is never rethrown, since the runtime's own alarm retries would run the sweep
|
|
71
|
+
* again at once, which the sweep's crash back-off exists to prevent.
|
|
72
|
+
*/
|
|
73
|
+
run(env: Env, connection: ConnectionSweepRef): Promise<ConnectionSweepRun>;
|
|
74
|
+
/** Default {@link CONNECTION_SWEEP_INTERVAL_MS}. */
|
|
75
|
+
intervalMs?: number;
|
|
76
|
+
/** Default {@link CONNECTION_SWEEP_OVERDUE_MS}. */
|
|
77
|
+
overdueAfterMs?: number;
|
|
78
|
+
/** Delay before a connection's first run. Default: spread over {@link CONNECTION_SWEEP_FIRST_SPREAD_MS} by id. */
|
|
79
|
+
firstDelayMs?(connectionId: string): number;
|
|
80
|
+
onError?(err: unknown, env: Env): void;
|
|
81
|
+
}
|
|
82
|
+
export declare function defineConnectionSweepDO<Env>(config: ConnectionSweepConfig<Env>): new (ctx: DurableObjectState, env: Env) => DurableObject<Env> & ConnectionSweepDo;
|
|
83
|
+
//# sourceMappingURL=connection-sweep-do.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-sweep-do.d.ts","sourceRoot":"","sources":["../src/connection-sweep-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AAEH,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,I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qBAAqB,CAAC,GAAG,CAAC,GACjC,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,aAAa,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAwDnF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
2
|
+
/** The one object per connection: `ns.get(ns.idFromName(connectionSweepName(connectionId)))`. */
|
|
3
|
+
export function connectionSweepName(connectionId) {
|
|
4
|
+
return `connection:${connectionId}`;
|
|
5
|
+
}
|
|
6
|
+
/** A connection's default interval between runs: the pass's cadence, as each connection had. */
|
|
7
|
+
export const CONNECTION_SWEEP_INTERVAL_MS = 15 * 60_000;
|
|
8
|
+
/** How far past its time an armed alarm may be before the check calls it overdue: K-69's hour. */
|
|
9
|
+
export const CONNECTION_SWEEP_OVERDUE_MS = 60 * 60_000;
|
|
10
|
+
/**
|
|
11
|
+
* The window a connection's first run is spread over, by its id. Handing every connection over in one
|
|
12
|
+
* pass would otherwise start every sweep in the same second.
|
|
13
|
+
*/
|
|
14
|
+
export const CONNECTION_SWEEP_FIRST_SPREAD_MS = 5 * 60_000;
|
|
15
|
+
/** The least gap between two runs, so a sweep that answers a time already gone never spins. */
|
|
16
|
+
const MIN_GAP_MS = 60_000;
|
|
17
|
+
/** A stable spread of `[0, spreadMs)` by a connection's id. */
|
|
18
|
+
export function spreadOf(connectionId, spreadMs) {
|
|
19
|
+
// FNV-1a, then a finalizing mix: ids that differ only in a last character still land far apart.
|
|
20
|
+
let h = 0x811c9dc5;
|
|
21
|
+
for (let i = 0; i < connectionId.length; i += 1)
|
|
22
|
+
h = Math.imul(h ^ connectionId.charCodeAt(i), 0x01000193);
|
|
23
|
+
h = Math.imul(h ^ (h >>> 16), 0x85ebca6b);
|
|
24
|
+
h = Math.imul(h ^ (h >>> 13), 0xc2b2ae35);
|
|
25
|
+
h = (h ^ (h >>> 16)) >>> 0;
|
|
26
|
+
return spreadMs > 0 ? h % spreadMs : 0;
|
|
27
|
+
}
|
|
28
|
+
const KEY = 'connection';
|
|
29
|
+
const sameRef = (a, b) => a.id === b.id && a.tenantId === b.tenantId && a.vertical === b.vertical && a.provider === b.provider;
|
|
30
|
+
export function defineConnectionSweepDO(config) {
|
|
31
|
+
const intervalMs = config.intervalMs ?? CONNECTION_SWEEP_INTERVAL_MS;
|
|
32
|
+
const overdueAfterMs = config.overdueAfterMs ?? CONNECTION_SWEEP_OVERDUE_MS;
|
|
33
|
+
const firstDelayMs = config.firstDelayMs ?? ((id) => spreadOf(id, CONNECTION_SWEEP_FIRST_SPREAD_MS));
|
|
34
|
+
return class ConnectionSweepDO extends DurableObject {
|
|
35
|
+
/**
|
|
36
|
+
* The pass's check (K-69): make sure this connection's alarm is armed, and say what was found.
|
|
37
|
+
* Never runs the sweep itself, so the pass is never held by a connection's provider.
|
|
38
|
+
*/
|
|
39
|
+
async ensure(connection) {
|
|
40
|
+
const stored = await this.ctx.storage.get(KEY);
|
|
41
|
+
if (stored && stored.id !== connection.id) {
|
|
42
|
+
throw new Error(`this object sweeps connection ${stored.id}, not ${connection.id}`);
|
|
43
|
+
}
|
|
44
|
+
if (!stored || !sameRef(stored, connection))
|
|
45
|
+
await this.ctx.storage.put(KEY, connection);
|
|
46
|
+
const at = await this.ctx.storage.getAlarm();
|
|
47
|
+
const now = Date.now();
|
|
48
|
+
if (at === null) {
|
|
49
|
+
await this.ctx.storage.setAlarm(now + Math.max(0, firstDelayMs(connection.id)));
|
|
50
|
+
return 'started';
|
|
51
|
+
}
|
|
52
|
+
if (at < now - overdueAfterMs) {
|
|
53
|
+
await this.ctx.storage.setAlarm(now);
|
|
54
|
+
return 'overdue';
|
|
55
|
+
}
|
|
56
|
+
return 'held';
|
|
57
|
+
}
|
|
58
|
+
async alarm() {
|
|
59
|
+
const connection = await this.ctx.storage.get(KEY);
|
|
60
|
+
if (!connection || !config.owned(this.env)) {
|
|
61
|
+
await this.#clear();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let run = {};
|
|
65
|
+
try {
|
|
66
|
+
run = await config.run(this.env, connection);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (config.onError)
|
|
70
|
+
config.onError(err, this.env);
|
|
71
|
+
else
|
|
72
|
+
console.error('connection sweep: the run failed; the next is armed at the interval', { connectionId: connection.id, err });
|
|
73
|
+
}
|
|
74
|
+
if (run.gone) {
|
|
75
|
+
await this.#clear();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// From the run's end: a provider's poll interval is judged against the outcome row its sweep
|
|
79
|
+
// writes as it ends, so an interval from the start would wake the object only to wait it out.
|
|
80
|
+
const next = run.notBefore ?? Date.now() + (run.intervalMs ?? intervalMs);
|
|
81
|
+
await this.ctx.storage.setAlarm(Math.max(next, Date.now() + MIN_GAP_MS));
|
|
82
|
+
}
|
|
83
|
+
async #clear() {
|
|
84
|
+
await this.ctx.storage.deleteAlarm();
|
|
85
|
+
await this.ctx.storage.deleteAll();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=connection-sweep-do.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-sweep-do.js","sourceRoot":"","sources":["../src/connection-sweep-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAqDnD,iGAAiG;AACjG,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,OAAO,cAAc,YAAY,EAAE,CAAC;AACtC,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,GAAG,MAAM,CAAC;AAExD,kGAAkG;AAClG,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,MAAM,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,GAAG,MAAM,CAAC;AAE3D,+FAA+F;AAC/F,MAAM,UAA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GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -5,6 +5,8 @@ import { type DoReply } from './do-reply.js';
|
|
|
5
5
|
import { type InstallsReconciled, type ServingPointer } from '@substrat-run/kernel';
|
|
6
6
|
import { type SubjectErasureFence, type ScopeCopyBackfillResult, type ExpectedServing, type ServedFrom, type ScopeCopyMoveConfirmation, type ScopeCopyRole, type ScopeScriptCopyRow } from '@substrat-run/kernel';
|
|
7
7
|
import { type RouteReadModelFlush, type RouteReadModelStatus } from './route-read-model-publisher.js';
|
|
8
|
+
import { type PeerCallTargetRow } from './peer-call-target.js';
|
|
9
|
+
import { type MirrorFlush, type MirrorStatus } from './directory-mirror.js';
|
|
8
10
|
import type { AdminLogEntry, OnBehalfOf, DeclaredMigration, ListPage, OpsFailureEntry, SweepRunEntry, RoleDefinition, DirectoryCopyByReference, DirectoryDumpPage, ScopeDumpTable, ScopeStatus, ScopeStorageSample, RequestDay, RequestRollupDay, CostDay, MeterDay, MeterDayTake, StaleScope, StaleScopeTake, VerticalOwnerPeriod, Tenant, TenantId, TenantStatus, PeerInstanceResolution, VerticalResolution, ErrorCode } from '@substrat-run/contracts';
|
|
9
11
|
import type { DeploymentWireAuth, FindingEntry, FindingFilter, FindingRuleEntry, FindingRuleInput, FindingStatusInput } from '@substrat-run/contracts';
|
|
10
12
|
import type { ConnectLink, ConnectLinkConsume } from '@substrat-run/contracts';
|
|
@@ -166,33 +168,7 @@ export interface RouteRow {
|
|
|
166
168
|
* and it must stay a range read on `hostnames_scope`, never a scan.
|
|
167
169
|
*/
|
|
168
170
|
export declare const READ_ROUTE_SQL = "SELECT h.tenant_id, h.scope_id, h.vertical_slug, h.surface, h.region,\n COALESCE(s.serving_ref, vv.deployment_ref) AS deployment_ref,\n CASE WHEN s.serving_ref IS NOT NULL\n THEN json_extract(sv.manifest_json, '$.outbound')\n ELSE json_extract(vv.manifest_json, '$.outbound') END AS outbound_json,\n CASE WHEN s.serving_ref IS NOT NULL\n THEN json_extract(sv.manifest_json, '$.calls')\n ELSE json_extract(vv.manifest_json, '$.calls') END AS calls_json,\n -- #2207: the stores of the version the scope's script runs. A scope pinned to a\n -- script other than its vertical's current serving one (stamped at provision, a\n -- fork kept on its copy's script) runs a version this row cannot name: NULL, so\n -- its store calls are refused. The control plane reads the same rule\n -- (scopeStoresOf in control-plane-api).\n CASE WHEN s.serving_ref IS NULL\n THEN json_extract(vv.manifest_json, '$.scopeStores')\n WHEN s.serving_ref = vr.serving_ref\n THEN json_extract(sv.manifest_json, '$.scopeStores')\n ELSE NULL END AS scope_stores_json,\n s.kind, s.forked_from,\n (SELECT json_group_array(sh.hostname) FROM (\n -- INDEXED BY: unpinned, the planner reads hostnames_status \u2014 every active\n -- hostname in the fleet, per request. A range on the scope is what it is.\n SELECT hostname FROM hostnames INDEXED BY hostnames_scope\n WHERE scope_id = s.scope_id AND status = 'active'\n ORDER BY hostname LIMIT 50\n ) sh) AS scope_hostnames_json\n FROM hostnames h\n JOIN scopes s ON s.scope_id = h.scope_id AND s.tenant_id = h.tenant_id\n JOIN tenants t ON t.tenant_id = s.tenant_id\n LEFT JOIN vertical_versions vv ON vv.id = s.vertical_version_id\n LEFT JOIN verticals vr ON vr.slug = s.vertical\n LEFT JOIN vertical_versions sv ON sv.id = vr.serving_version_id\n WHERE h.hostname = ? AND h.status = 'active'\n AND s.status = 'active' AND t.status = 'active'";
|
|
169
|
-
|
|
170
|
-
export interface PeerCandidateRow {
|
|
171
|
-
scope_id: string;
|
|
172
|
-
tenant_id: string;
|
|
173
|
-
vertical: string | null;
|
|
174
|
-
status: string;
|
|
175
|
-
kind: string | null;
|
|
176
|
-
forked_from: string | null;
|
|
177
|
-
deployment_ref: string | null;
|
|
178
|
-
outbound_json: string | null;
|
|
179
|
-
calls_json: string | null;
|
|
180
|
-
}
|
|
181
|
-
/** Where the CALLER stands: usable, or the one reason it is not (#1706). */
|
|
182
|
-
export type PeerCallerState = 'ok' | 'unknown' | 'not-primary' | 'inactive';
|
|
183
|
-
/** What `peerCallTarget` answers: the caller's standing, and the resolved target (or why not). */
|
|
184
|
-
export interface PeerCallTargetRow {
|
|
185
|
-
/** `tenantSlug`: the directory's slug for the caller's tenant (#2252), for the target's door. */
|
|
186
|
-
caller: {
|
|
187
|
-
state: PeerCallerState;
|
|
188
|
-
status: string | null;
|
|
189
|
-
tenantSlug: string | null;
|
|
190
|
-
};
|
|
191
|
-
outcome: 'resolved' | 'not-installed' | 'ambiguous' | 'bound-unavailable';
|
|
192
|
-
/** How many live instances, when `ambiguous`. Zero otherwise. */
|
|
193
|
-
count: number;
|
|
194
|
-
target: PeerCandidateRow | null;
|
|
195
|
-
}
|
|
171
|
+
export type { PeerCallTargetRow, PeerCallerState, PeerCandidateRow } from './peer-call-target.js';
|
|
196
172
|
export interface VerticalRow {
|
|
197
173
|
slug: string;
|
|
198
174
|
name: string;
|
|
@@ -213,6 +189,9 @@ export interface VerticalRow {
|
|
|
213
189
|
tenant_provisioner: number;
|
|
214
190
|
/** Email-sender capability (0/1, #303) — staff grant; never touched by a re-push. */
|
|
215
191
|
email_sender: number;
|
|
192
|
+
/** The owner's Workers trace rates (0–1, #3358) — serving and preview scripts; NULL reads as 0. Never touched by a re-push. */
|
|
193
|
+
trace_sampling: number | null;
|
|
194
|
+
preview_trace_sampling: number | null;
|
|
216
195
|
/** The stable serving script's name (#286); null = no serving script yet. */
|
|
217
196
|
serving_ref: string | null;
|
|
218
197
|
/** The version whose bundle the serving script currently runs (may trail prod). */
|
|
@@ -353,6 +332,9 @@ export interface ModelUsageRow {
|
|
|
353
332
|
list_usd: string | null;
|
|
354
333
|
at: string;
|
|
355
334
|
elapsed_ms: number;
|
|
335
|
+
/** #3321: NULL on a token line. */
|
|
336
|
+
unit: string | null;
|
|
337
|
+
quantity: number | null;
|
|
356
338
|
}
|
|
357
339
|
/** The model-usage filter, flattened for the RPC hop (#1054). */
|
|
358
340
|
export interface ModelUsageQuery {
|
|
@@ -529,7 +511,7 @@ export declare const BACKFILL_FAILURES_KEY = "versionMigrationsBackfillFailures"
|
|
|
529
511
|
/** How long the backfill waits after its `failures`-th failure in a row: doubling, capped. */
|
|
530
512
|
export declare function backfillBackoffMs(failures: number): number;
|
|
531
513
|
/** The directory writes `ControlPlaneDO.reply` answers for (#113): each refuses with a typed throw. */
|
|
532
|
-
export declare const REPLIED_METHODS: readonly ['createTenant', 'setTenantStatus', 'markScopeStoresFenced', 'reapTenant', 'setTenantName', 'putTenantStore', 'putBlobStore', 'provisionScope', 'createOrg', 'registerIdentityPool', 'linkIdentity', 'createFindingRule', 'insertVersion', 'verticalScopeStores', 'recordStoreDriverRelease', 'approveStoreDriverReleaseAndAudit', 'recordStoreDriverRevokeWalk', 'revokeStoreDriverReleaseAndAudit', 'storeDriverDeclarations', 'storeDriverRolloutPending', 'storeDriverRolloutWalked', 'holdStoreDriver', 'beginStoreDriverRollout', 'finishStoreDriverRollout', 'claimStoreDriverRebuild', 'advanceStoreDriverRebuild', 'updateVerticalListed', 'updateVerticalPublishRequest', 'updateVerticalInstallsBlocked', 'updateVerticalTenantProvisioner', 'updateVerticalEmailSender', 'deleteVertical', 'admitVersion', 'rejectVersion', 'setVerticalServing', 'promoteChannel', 'defineRoleOrRefusal', 'assignTenantRole', 'writeTenantTuple', 'writeOrgTenantTuple', 'writeTenantSystemGrant', 'grantConnectionInDirectory', 'revokeConnectionGrantInDirectory', 'insertOrg', 'bindHostnameInDirectory', 'setHostnameStatus', 'setHostnameIssuance', 'deleteHostname', 'grantEntitlement', 'revokeEntitlement', 'putTenantStoreAndAudit', 'putBlobStoreAndAudit', 'recordStoreDriverReleaseAndAudit', 'beginStoreDriverRolloutAndAudit', 'finishStoreDriverRolloutAndAudit', 'importDumpAndAudit', 'registerIdentityPoolAndAudit', 'insertConnectionAndAudit', 'updateConnectionSecretAndAudit', 'revokeConnectionAndAudit', 'linkIdentityAndAudit', 'unlinkIdentityAndAudit', 'markAccessLogDrainedAndAudit', 'pruneAccessLogAndAudit', 'setDirectoryLakeCapture', 'ackDirectoryOutbox', 'advanceDirectoryLakeBackfill', 'pruneDirectoryLakeWindow', 'writeImpersonationAndAudit', 'endImpersonationAndAudit', 'setIssueStatusAndAudit'];
|
|
514
|
+
export declare const REPLIED_METHODS: readonly ['createTenant', 'setTenantStatus', 'markScopeStoresFenced', 'reapTenant', 'setTenantName', 'putTenantStore', 'putBlobStore', 'provisionScope', 'createOrg', 'registerIdentityPool', 'linkIdentity', 'createFindingRule', 'insertVersion', 'verticalScopeStores', 'recordStoreDriverRelease', 'approveStoreDriverReleaseAndAudit', 'recordStoreDriverRevokeWalk', 'revokeStoreDriverReleaseAndAudit', 'storeDriverDeclarations', 'storeDriverRolloutPending', 'storeDriverRolloutWalked', 'holdStoreDriver', 'beginStoreDriverRollout', 'finishStoreDriverRollout', 'claimStoreDriverRebuild', 'advanceStoreDriverRebuild', 'updateVerticalListed', 'updateVerticalPublishRequest', 'updateVerticalInstallsBlocked', 'updateVerticalTenantProvisioner', 'updateVerticalEmailSender', 'updateVerticalTraceSampling', 'deleteVertical', 'admitVersion', 'rejectVersion', 'setVerticalServing', 'promoteChannel', 'defineRoleOrRefusal', 'assignTenantRole', 'writeTenantTuple', 'writeOrgTenantTuple', 'writeTenantSystemGrant', 'grantConnectionInDirectory', 'revokeConnectionGrantInDirectory', 'insertOrg', 'bindHostnameInDirectory', 'setHostnameStatus', 'setHostnameIssuance', 'deleteHostname', 'grantEntitlement', 'revokeEntitlement', 'putTenantStoreAndAudit', 'putBlobStoreAndAudit', 'recordStoreDriverReleaseAndAudit', 'beginStoreDriverRolloutAndAudit', 'finishStoreDriverRolloutAndAudit', 'importDumpAndAudit', 'registerIdentityPoolAndAudit', 'insertConnectionAndAudit', 'updateConnectionSecretAndAudit', 'revokeConnectionAndAudit', 'linkIdentityAndAudit', 'unlinkIdentityAndAudit', 'markAccessLogDrainedAndAudit', 'pruneAccessLogAndAudit', 'setDirectoryLakeCapture', 'ackDirectoryOutbox', 'advanceDirectoryLakeBackfill', 'pruneDirectoryLakeWindow', 'writeImpersonationAndAudit', 'endImpersonationAndAudit', 'setIssueStatusAndAudit'];
|
|
533
515
|
export type RepliedMethod = (typeof REPLIED_METHODS)[number];
|
|
534
516
|
export declare class ControlPlaneDO extends DurableObject {
|
|
535
517
|
private readonly sql;
|
|
@@ -538,6 +520,15 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
538
520
|
/** Settles once the constructor's #1764 backfill check has run (awaited by the tests). */
|
|
539
521
|
readonly backfillArmed: Promise<void>;
|
|
540
522
|
constructor(ctx: DurableObjectState, env: unknown);
|
|
523
|
+
/** Set where `DIRECTORY_MIRROR` is on and the two object namespaces are bound; null otherwise. */
|
|
524
|
+
private readonly directoryMirror;
|
|
525
|
+
/** Flush what the outbox holds. Called when the outermost method returns, like the route kick. */
|
|
526
|
+
kickDirectoryMirror(): void;
|
|
527
|
+
/** Drain the outbox now, for a caller (and a test) that must see the copy land. */
|
|
528
|
+
settleDirectoryMirror(): Promise<MirrorFlush | null>;
|
|
529
|
+
directoryMirrorStatus(): MirrorStatus | {
|
|
530
|
+
enabled: false;
|
|
531
|
+
};
|
|
541
532
|
/** Set where a `ROUTES` KV namespace is bound; null otherwise, and the read model is off. */
|
|
542
533
|
private routePublisher;
|
|
543
534
|
private routeFlushing;
|
|
@@ -770,15 +761,23 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
770
761
|
private checkReferences;
|
|
771
762
|
private hasCopyTable;
|
|
772
763
|
/**
|
|
773
|
-
* Copy every dumped table into a fresh snapshot (#2868),
|
|
774
|
-
* and
|
|
775
|
-
*
|
|
764
|
+
* Copy every dumped table into a fresh snapshot (#2868), and return the cursor of its first page
|
|
765
|
+
* and how many tables it holds. One synchronous transaction, so no write lands between two
|
|
766
|
+
* tables' reads. A snapshot a copy left unfinished is dropped before it (`dropLeftoverSnapshot`,
|
|
767
|
+
* #3422); the drop here only catches one a concurrent first page made in between.
|
|
776
768
|
*
|
|
777
769
|
* #3325: under `on`, a by-reference table is not copied; its horizon (largest rowid) and row
|
|
778
770
|
* count are recorded instead, which costs no row written. Under `verify` it is copied as before,
|
|
779
771
|
* each row at its source rowid, so the last page can compare it with the live table.
|
|
780
772
|
*/
|
|
781
773
|
private snapshotDirectory;
|
|
774
|
+
/**
|
|
775
|
+
* #3422: drop the snapshot a copy left unfinished, one table per turn. Writes with no `await`
|
|
776
|
+
* between them commit as one transaction, so each drop is followed by a timer, which ends the turn
|
|
777
|
+
* and commits it. The snapshot's own transaction then has nothing left to drop. A failed
|
|
778
|
+
* snapshot rolls back only its own writes, so the leftover stays gone.
|
|
779
|
+
*/
|
|
780
|
+
private dropLeftoverSnapshot;
|
|
782
781
|
private dropDirectorySnapshot;
|
|
783
782
|
/**
|
|
784
783
|
* The tables a dump carries, by name. Not `_cf_*` either: workerd's own tables (the #1764
|
|
@@ -923,6 +922,7 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
923
922
|
sourceReferences: StoreDriverApprovalRecord['sourceReferences'];
|
|
924
923
|
isolationReview: StoreDriverApprovalRecord['isolationReview'];
|
|
925
924
|
schema: number;
|
|
925
|
+
foundation?: number;
|
|
926
926
|
className: string;
|
|
927
927
|
operations: readonly string[];
|
|
928
928
|
actor: string;
|
|
@@ -1230,19 +1230,18 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
1230
1230
|
previous: string | null;
|
|
1231
1231
|
};
|
|
1232
1232
|
/**
|
|
1233
|
-
* Everything the router needs to place ONE peer call (#1706), in one round trip: the
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1233
|
+
* Everything the router needs to place ONE peer call (#1706), in one round trip: the CALLER's
|
|
1234
|
+
* own scope record, and the target instance of `vertical` in that tenant with the script and
|
|
1235
|
+
* dispatch parameters that instance runs under (`readPeerCallTarget`, which the routing read
|
|
1236
|
+
* model publishes from too).
|
|
1236
1237
|
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
* the vertical it claims — and it is read HERE rather than inferred from routing, so this
|
|
1241
|
-
* path does not inherit #1713.
|
|
1242
|
-
* The target side applies the kernel's one rule (`resolvePeerInstanceFrom`), the same
|
|
1243
|
-
* rule the pure host and the local broker apply.
|
|
1238
|
+
* `publish` (#3395, K-72) is the router's read-model miss: a dispatchable answer is queued for
|
|
1239
|
+
* publishing unless it is published already. A directory that predates it ignores the argument.
|
|
1240
|
+
* The answer is the same either way.
|
|
1244
1241
|
*/
|
|
1245
|
-
peerCallTarget(tenantId: string, callerScopeId: string, callerVertical: string, vertical: string
|
|
1242
|
+
peerCallTarget(tenantId: string, callerScopeId: string, callerVertical: string, vertical: string, opts?: {
|
|
1243
|
+
publish?: boolean;
|
|
1244
|
+
}): PeerCallTargetRow;
|
|
1246
1245
|
/**
|
|
1247
1246
|
* Request-path gate: only an active hostname, correctly paired active scope and active
|
|
1248
1247
|
* owning tenant resolve (#1713). No lifecycle fields cross the wire: refusal is the existing
|
|
@@ -1361,6 +1360,8 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
1361
1360
|
updateVerticalTenantProvisioner(slug: string, granted: number, audit?: AdminEntryInput): void;
|
|
1362
1361
|
/** Grant/revoke the email-sender capability (#303, staff grant). */
|
|
1363
1362
|
updateVerticalEmailSender(slug: string, granted: number, audit?: AdminEntryInput): void;
|
|
1363
|
+
/** Set the owner's Workers trace rates (#3358). */
|
|
1364
|
+
updateVerticalTraceSampling(slug: string, serving: number, previews: number, audit?: AdminEntryInput): void;
|
|
1364
1365
|
/**
|
|
1365
1366
|
* #2528: one vertical row update whose row reads its `before` (and runs its guard, by throwing)
|
|
1366
1367
|
* from the vertical as this unit reads it, so neither can be stale against the write.
|
|
@@ -2073,6 +2074,17 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
2073
2074
|
wrappedDek: string | null;
|
|
2074
2075
|
shreddedAt: string | null;
|
|
2075
2076
|
} | undefined;
|
|
2077
|
+
/**
|
|
2078
|
+
* #3464: several subjects' key rows in one call, for a sealer that seals a whole lake batch at
|
|
2079
|
+
* once. Read-only and outside any transaction, like `readSubjectKey`. Chunked under the bound
|
|
2080
|
+
* parameter limit a Durable Object's SQLite enforces (K-49's `assertWithinSqlLimits`).
|
|
2081
|
+
*/
|
|
2082
|
+
readSubjectKeys(scopeId: string, subjectIds: readonly string[]): {
|
|
2083
|
+
subjectId: string;
|
|
2084
|
+
keyId: string | null;
|
|
2085
|
+
wrappedDek: string | null;
|
|
2086
|
+
shreddedAt: string | null;
|
|
2087
|
+
}[];
|
|
2076
2088
|
listShreddedSubjects(scopeId: string, tenantId: string, cursor: string | null): string[];
|
|
2077
2089
|
/**
|
|
2078
2090
|
* `OR IGNORE`, not `OR REPLACE`: two exports of the same subject can race to mint, and
|
|
@@ -2231,5 +2243,4 @@ export declare class ControlPlaneDO extends DurableObject {
|
|
|
2231
2243
|
listMarkupRows(tenantId?: string): MarkupScheduleRecord[];
|
|
2232
2244
|
listTenantModelUsageMeter(query: TenantModelUsageMeterFilter): TenantModelUsageMeterRow[];
|
|
2233
2245
|
}
|
|
2234
|
-
export {};
|
|
2235
2246
|
//# sourceMappingURL=control-plane-do.d.ts.map
|