@substrat-run/kernel 0.220.0 → 0.222.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/adopt-major.d.ts +150 -0
- package/dist/adopt-major.d.ts.map +1 -0
- package/dist/adopt-major.js +150 -0
- package/dist/adopt-major.js.map +1 -0
- package/dist/app-environments.d.ts +173 -3
- package/dist/app-environments.d.ts.map +1 -1
- package/dist/app-environments.js +334 -5
- package/dist/app-environments.js.map +1 -1
- package/dist/broker-counts.d.ts +8 -30
- package/dist/broker-counts.d.ts.map +1 -1
- package/dist/broker-counts.js +41 -6
- package/dist/broker-counts.js.map +1 -1
- package/dist/broker-shadow.d.ts +3 -0
- package/dist/broker-shadow.d.ts.map +1 -1
- package/dist/broker-shadow.js +1 -0
- package/dist/broker-shadow.js.map +1 -1
- package/dist/broker-telemetry.d.ts +11 -0
- package/dist/broker-telemetry.d.ts.map +1 -1
- package/dist/broker-telemetry.js +5 -0
- package/dist/broker-telemetry.js.map +1 -1
- package/dist/carried-copy.d.ts.map +1 -1
- package/dist/carried-copy.js +5 -0
- package/dist/carried-copy.js.map +1 -1
- package/dist/credential-bound-fetch.d.ts +73 -0
- package/dist/credential-bound-fetch.d.ts.map +1 -0
- package/dist/credential-bound-fetch.js +241 -0
- package/dist/credential-bound-fetch.js.map +1 -0
- package/dist/delivery-broker.d.ts +24 -5
- package/dist/delivery-broker.d.ts.map +1 -1
- package/dist/delivery-broker.js +30 -7
- package/dist/delivery-broker.js.map +1 -1
- package/dist/delivery-contract.d.ts +29 -3
- package/dist/delivery-contract.d.ts.map +1 -1
- package/dist/delivery-contract.js +85 -1
- package/dist/delivery-contract.js.map +1 -1
- package/dist/dependent-erasure.d.ts +106 -0
- package/dist/dependent-erasure.d.ts.map +1 -0
- package/dist/dependent-erasure.js +150 -0
- package/dist/dependent-erasure.js.map +1 -0
- package/dist/directory-lake-keep.d.ts.map +1 -1
- package/dist/directory-lake-keep.js +7 -0
- package/dist/directory-lake-keep.js.map +1 -1
- package/dist/home-scope.d.ts +87 -0
- package/dist/home-scope.d.ts.map +1 -0
- package/dist/home-scope.js +110 -0
- package/dist/home-scope.js.map +1 -0
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/dist/module-operations.d.ts +9 -0
- package/dist/module-operations.d.ts.map +1 -1
- package/dist/module-operations.js +22 -0
- package/dist/module-operations.js.map +1 -1
- package/dist/owned-reaps.d.ts +73 -0
- package/dist/owned-reaps.d.ts.map +1 -0
- package/dist/owned-reaps.js +71 -0
- package/dist/owned-reaps.js.map +1 -0
- package/dist/permission-checker.d.ts.map +1 -1
- package/dist/permission-checker.js +4 -2
- package/dist/permission-checker.js.map +1 -1
- package/dist/platform-sweep.d.ts +14 -1
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +117 -59
- package/dist/platform-sweep.js.map +1 -1
- package/dist/relay-intents.d.ts +38 -0
- package/dist/relay-intents.d.ts.map +1 -0
- package/dist/relay-intents.js +45 -0
- package/dist/relay-intents.js.map +1 -0
- package/dist/release-within-major.d.ts +54 -2
- package/dist/release-within-major.d.ts.map +1 -1
- package/dist/release-within-major.js +80 -6
- package/dist/release-within-major.js.map +1 -1
- package/dist/reserved-roles.d.ts +6 -1
- package/dist/reserved-roles.d.ts.map +1 -1
- package/dist/reserved-roles.js.map +1 -1
- package/dist/schedule-due.d.ts +88 -0
- package/dist/schedule-due.d.ts.map +1 -0
- package/dist/schedule-due.js +116 -0
- package/dist/schedule-due.js.map +1 -0
- package/dist/schedule-state.d.ts +1 -1
- package/dist/schedule-state.d.ts.map +1 -1
- package/dist/schedule-state.js +6 -0
- package/dist/schedule-state.js.map +1 -1
- package/dist/scope-copy-ledger.d.ts +5 -0
- package/dist/scope-copy-ledger.d.ts.map +1 -1
- package/dist/scope-copy-ledger.js +8 -0
- package/dist/scope-copy-ledger.js.map +1 -1
- package/dist/scope-copy.d.ts.map +1 -1
- package/dist/scope-copy.js +7 -1
- package/dist/scope-copy.js.map +1 -1
- package/dist/scope-host.d.ts +234 -3
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js.map +1 -1
- package/dist/scope-store.d.ts +30 -6
- package/dist/scope-store.d.ts.map +1 -1
- package/dist/scope-store.js +30 -1
- package/dist/scope-store.js.map +1 -1
- package/dist/scope-types.d.ts +122 -3
- package/dist/scope-types.d.ts.map +1 -1
- package/dist/scope-types.js +172 -2
- package/dist/scope-types.js.map +1 -1
- package/dist/store-proof.d.ts +45 -0
- package/dist/store-proof.d.ts.map +1 -0
- package/dist/store-proof.js +97 -0
- package/dist/store-proof.js.map +1 -0
- package/package.json +2 -2
package/dist/app-environments.js
CHANGED
|
@@ -13,11 +13,35 @@
|
|
|
13
13
|
* written only over a preview that exists, is active and is pinned (no expiry), so an environment is
|
|
14
14
|
* never a pointer without scopes, which is what `dev` and `staging` were when #509 retired them.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* a
|
|
16
|
+
* **A named environment may serve from a script of its own** (#3530 step 4). Its first serve uploads
|
|
17
|
+
* a version onto a fresh script and moves the preview's data there once; every later serve replaces
|
|
18
|
+
* that script in place and moves only the version pointer, as production's serve does (K-33). The
|
|
19
|
+
* record is four columns on the row (`APP_ENVIRONMENT_SERVING_COLUMNS`), NULL until the first serve,
|
|
20
|
+
* so a row from before reads as an environment with no script, which is what it is. The script is
|
|
21
|
+
* fixed for the environment's life: a serve that names another one is refused.
|
|
22
|
+
*
|
|
23
|
+
* **A named environment causes no outside effects unless a person gives it connections of its own**
|
|
24
|
+
* (#3530 step 6). The choice is one column on the row (`effects`, NULL read as `none`), and the one
|
|
25
|
+
* rule every connection door asks is `connectionReachIn`: an install reaches the tenant's connections
|
|
26
|
+
* and its own, the scope of an environment given connections of its own reaches its own alone, and
|
|
27
|
+
* every other scope that is not an install reaches none. It never inherits production's.
|
|
28
|
+
*
|
|
29
|
+
* **A serve into a named environment is judged by the two checkpoints against what it serves**
|
|
30
|
+
* (#3638, D-83's third position). The version it serves is its own script's, or before its first
|
|
31
|
+
* serve its preview's bound version (`environmentServedVersionIn`). A serve whose permission or
|
|
32
|
+
* migration digest differs from that version's is refused until it is acknowledged for this serve
|
|
33
|
+
* (`environmentCheckpointRefusal`), and the acknowledgement lands in this environment's serve
|
|
34
|
+
* record, so it never counts for another environment, and a promote's never counts here.
|
|
35
|
+
*
|
|
36
|
+
* **A broker per environment** (#3639): the scope of an environment given connections of its own hands
|
|
37
|
+
* its messages off to that environment's broker (`deliveryEnvironmentIn`), never production's, whose
|
|
38
|
+
* name does not change. Every other scope that is not an install hands off nothing.
|
|
39
|
+
*
|
|
40
|
+
* What is deliberately not here: edges between environments (D-83 step 5). A named environment's
|
|
41
|
+
* scope is a preview, so everything but its own connections and its own broker stays inert.
|
|
18
42
|
*/
|
|
19
|
-
import { PRODUCTION_ENVIRONMENT, environmentName, substratError } from '@substrat-run/contracts';
|
|
20
|
-
import { isPrimaryScopeRow } from './scope-identity.js';
|
|
43
|
+
import { ENVIRONMENT_CHECKPOINT_REASON, PRODUCTION_ENVIRONMENT, environmentName, substratError, } from '@substrat-run/contracts';
|
|
44
|
+
import { isPrimaryScope, isPrimaryScopeRow } from './scope-identity.js';
|
|
21
45
|
/** Directory-owned, on both adapters. One row per named environment; production has none. */
|
|
22
46
|
export const APP_ENVIRONMENTS_DDL = `
|
|
23
47
|
CREATE TABLE IF NOT EXISTS app_environments (
|
|
@@ -29,6 +53,50 @@ export const APP_ENVIRONMENTS_DDL = `
|
|
|
29
53
|
PRIMARY KEY (tenant_id, vertical, name)
|
|
30
54
|
);
|
|
31
55
|
`;
|
|
56
|
+
/**
|
|
57
|
+
* #3530 step 4: what an environment's own serving script runs, ALTERed onto `app_environments` by
|
|
58
|
+
* both adapters (and copied into the K-68 objects' column list), all NULL until its first serve.
|
|
59
|
+
* `serving_ref` is the script; `serving_version_id` the version last uploaded onto it;
|
|
60
|
+
* `serving_do_classes` (JSON array) and `serving_migration_tag` what the next in-place upload diffs
|
|
61
|
+
* its Durable Object migrations against, as `verticals.serving_*` are for production.
|
|
62
|
+
*/
|
|
63
|
+
export const APP_ENVIRONMENT_SERVING_COLUMNS = [
|
|
64
|
+
'serving_ref TEXT',
|
|
65
|
+
'serving_version_id TEXT',
|
|
66
|
+
'serving_do_classes TEXT',
|
|
67
|
+
'serving_migration_tag TEXT',
|
|
68
|
+
// The serve in flight: its claim id and the instant its lease ends. A serve uploads onto the
|
|
69
|
+
// script before it records, so two at once could leave the script running the one whose record
|
|
70
|
+
// lost; the lease makes them one at a time (`claimEnvironmentServeIn`).
|
|
71
|
+
'serve_claim TEXT',
|
|
72
|
+
'serve_claimed_until TEXT',
|
|
73
|
+
];
|
|
74
|
+
/**
|
|
75
|
+
* #3530 step 6: a named environment's choice of outside effects, ALTERed onto `app_environments` by
|
|
76
|
+
* both adapters (and copied into the K-68 objects' column list). NULL on every row from before it,
|
|
77
|
+
* which reads as `none`: the inert default every preview has.
|
|
78
|
+
*/
|
|
79
|
+
export const APP_ENVIRONMENT_EFFECTS_COLUMNS = ['effects TEXT'];
|
|
80
|
+
const effectsOfColumn = (v) => (v === 'own-connections' ? 'own-connections' : 'none');
|
|
81
|
+
/**
|
|
82
|
+
* SQL: joins `ae`, the environment whose own script the scope `s` is served from, to a read over
|
|
83
|
+
* `scopes s`. Null for every scope that is not on one: production's installs, a preview on its
|
|
84
|
+
* version's script, a fork on its copy's. Keyed by the table's primary key prefix, so it is a range
|
|
85
|
+
* read of one tenant's environments of one app, empty for an app that has none.
|
|
86
|
+
*/
|
|
87
|
+
export const ENVIRONMENT_SCRIPT_JOIN_SQL = 'LEFT JOIN app_environments ae ON ae.tenant_id = s.tenant_id AND ae.vertical = s.vertical AND ae.serving_ref = s.serving_ref';
|
|
88
|
+
const servingOfRow = (r) => r.serving_ref && r.serving_version_id
|
|
89
|
+
? {
|
|
90
|
+
ref: r.serving_ref,
|
|
91
|
+
versionId: r.serving_version_id,
|
|
92
|
+
doClasses: r.serving_do_classes ? JSON.parse(r.serving_do_classes) : [],
|
|
93
|
+
migrationTag: r.serving_migration_tag ?? 'v1',
|
|
94
|
+
}
|
|
95
|
+
: null;
|
|
96
|
+
const sameServing = (a, b) => a === null || b === null
|
|
97
|
+
? a === b
|
|
98
|
+
: a.ref === b.ref && a.versionId === b.versionId && a.migrationTag === b.migrationTag &&
|
|
99
|
+
JSON.stringify([...a.doClasses].sort()) === JSON.stringify([...b.doClasses].sort());
|
|
32
100
|
/**
|
|
33
101
|
* A preview's scope slug: `<app>--<tag>`, the app's last path segment (`t-acme/crm` → `crm`). The
|
|
34
102
|
* preview routes find a tag by it, and an environment finds its preview by it.
|
|
@@ -52,7 +120,8 @@ export function environmentsOf(sql, tenantId, vertical) {
|
|
|
52
120
|
scopeIds: scopes.filter((s) => isPrimaryScopeRow(s)).map((s) => s.scope_id),
|
|
53
121
|
createdAt: null, createdBy: null,
|
|
54
122
|
};
|
|
55
|
-
const rows = sql.all(
|
|
123
|
+
const rows = sql.all(`SELECT name, created_at, created_by, serving_ref, serving_version_id, serving_do_classes, serving_migration_tag, effects
|
|
124
|
+
FROM app_environments WHERE tenant_id = ? AND vertical = ? ORDER BY name`, tenantId, vertical);
|
|
56
125
|
return [
|
|
57
126
|
production,
|
|
58
127
|
...rows.map((r) => {
|
|
@@ -61,6 +130,8 @@ export function environmentsOf(sql, tenantId, vertical) {
|
|
|
61
130
|
tenantId, vertical, name: r.name, production: false,
|
|
62
131
|
scopeIds: preview ? [preview.scope_id] : [],
|
|
63
132
|
createdAt: r.created_at, createdBy: r.created_by,
|
|
133
|
+
serving: servingOfRow(r),
|
|
134
|
+
effects: effectsOfColumn(r.effects),
|
|
64
135
|
};
|
|
65
136
|
}),
|
|
66
137
|
];
|
|
@@ -110,7 +181,265 @@ export function removeEnvironmentIn(sql, input) {
|
|
|
110
181
|
if (!isEnvironmentTag(sql, tenantId, vertical, name))
|
|
111
182
|
return { removed: false, scopeId: null };
|
|
112
183
|
const preview = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name);
|
|
184
|
+
// #3530 step 4: an environment served from its own script keeps its data there. Taking the name
|
|
185
|
+
// off would leave a preview on a script nothing names, whose route then runs another version's
|
|
186
|
+
// policy, so the name goes only with the data (the preview reaped first) or before any serve. An
|
|
187
|
+
// archived preview counts: it keeps its data, and an unarchive would bring it back.
|
|
188
|
+
const serving = rowServing(sql, input);
|
|
189
|
+
if (serving && unreapedPreviewOf(sql, input)) {
|
|
190
|
+
throw substratError('conflict', `the environment '${name}' serves from a script of its own, where its data lives: delete the environment with ` +
|
|
191
|
+
`its data (substrat environment rm ${name} --delete-data), which reaps its preview first`);
|
|
192
|
+
}
|
|
113
193
|
sql.run('DELETE FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', tenantId, vertical, name);
|
|
114
194
|
return { removed: true, scopeId: preview?.scope_id ?? null };
|
|
115
195
|
}
|
|
196
|
+
/** The environment's preview while its row is kept, archived included: only a reap ends its data. */
|
|
197
|
+
const unreapedPreviewOf = (sql, input) => sql.all(`SELECT scope_id FROM scopes WHERE tenant_id = ? AND vertical = ? AND kind = 'preview' AND slug = ? AND status != 'reaped'`, input.tenantId, input.vertical, previewScopeSlug(input.vertical, input.name))[0]?.scope_id;
|
|
198
|
+
const rowServing = (sql, input) => {
|
|
199
|
+
const row = sql.all(`SELECT serving_ref, serving_version_id, serving_do_classes, serving_migration_tag
|
|
200
|
+
FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?`, input.tenantId, input.vertical, input.name)[0];
|
|
201
|
+
return row ? servingOfRow(row) : null;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The refusal of a serve into the named environment `name` that changes the permission surface or the
|
|
205
|
+
* migrations against `base`, the version the environment serves, and does not acknowledge it (#3638,
|
|
206
|
+
* D-83). Null when it may go on: nothing served yet (a first serve has nothing to diff, as a first
|
|
207
|
+
* promote has not), the same version again, the same digests, or each change acknowledged. Both
|
|
208
|
+
* checkpoints are named in one refusal, so one review answers them. `conflict`, as the promote's are;
|
|
209
|
+
* the problem document carries the environment and the base, which is what the review is read against.
|
|
210
|
+
*/
|
|
211
|
+
export function environmentCheckpointRefusal(name, base, incoming, acknowledge) {
|
|
212
|
+
if (base === null || base.id === incoming.id)
|
|
213
|
+
return null;
|
|
214
|
+
const unacknowledged = [];
|
|
215
|
+
if (base.permissionDigest !== incoming.permissionDigest && !acknowledge?.permissionChange)
|
|
216
|
+
unacknowledged.push('permissions');
|
|
217
|
+
if (base.migrationDigest !== incoming.migrationDigest && !acknowledge?.migrationChange)
|
|
218
|
+
unacknowledged.push('migrations');
|
|
219
|
+
if (unacknowledged.length === 0)
|
|
220
|
+
return null;
|
|
221
|
+
const what = unacknowledged.map((c) => c === 'permissions'
|
|
222
|
+
? `changes the permission surface (${base.permissionDigest} → ${incoming.permissionDigest})`
|
|
223
|
+
: `changes migrations (${base.migrationDigest} → ${incoming.migrationDigest})`);
|
|
224
|
+
return substratError('conflict', `serving ${incoming.id} in the environment '${name}' ${what.join(' and ')} against the version it serves (${base.id}): ` +
|
|
225
|
+
'acknowledge it in this environment to serve. An acknowledgement given in another environment or on a promote to ' +
|
|
226
|
+
'production does not count here', { reason: ENVIRONMENT_CHECKPOINT_REASON, environment: name, base: base.id, checkpoints: unacknowledged });
|
|
227
|
+
}
|
|
228
|
+
/** A version's two pushed digests from the directory, or null for a version it does not hold. */
|
|
229
|
+
export function checkpointSideIn(sql, versionId) {
|
|
230
|
+
const row = sql.all('SELECT id, permission_digest, migration_digest FROM vertical_versions WHERE id = ?', versionId)[0];
|
|
231
|
+
return row ? { id: row.id, permissionDigest: row.permission_digest, migrationDigest: row.migration_digest } : null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The version a named environment serves (#3638): what its own script runs, or before its first serve
|
|
235
|
+
* the version its preview is bound to. Null when it serves nothing: no such environment, or a preview
|
|
236
|
+
* that is gone or bound to no version.
|
|
237
|
+
*/
|
|
238
|
+
export function environmentServedVersionIn(sql, input) {
|
|
239
|
+
if (input.name === PRODUCTION_ENVIRONMENT || !isEnvironmentTag(sql, input.tenantId, input.vertical, input.name))
|
|
240
|
+
return null;
|
|
241
|
+
const serving = rowServing(sql, input);
|
|
242
|
+
if (serving)
|
|
243
|
+
return serving.versionId;
|
|
244
|
+
const preview = previewOf(liveScopesOf(sql, input.tenantId, input.vertical), input.vertical, input.name);
|
|
245
|
+
if (!preview)
|
|
246
|
+
return null;
|
|
247
|
+
const row = sql.all('SELECT vertical_version_id FROM scopes WHERE scope_id = ?', preview.scope_id)[0];
|
|
248
|
+
return row?.vertical_version_id ?? null;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Record what an environment's own script now runs (#3530 step 4), written only after the upload
|
|
252
|
+
* landed, in the caller's one directory transaction with its admin row. A compare-and-set on
|
|
253
|
+
* `expected`, the record the caller's upload diffed its migrations from (null: the first serve), as
|
|
254
|
+
* `setVerticalServing` is for production: `moved: false`, with nothing written, when the row holds
|
|
255
|
+
* another record now. Refused: a name that is no environment (`not_found`); another script than the
|
|
256
|
+
* one the environment already serves from (`conflict`, since the data lives there); a class set
|
|
257
|
+
* that drops a class the script already has (`validation_failed`: a class's storage cannot go).
|
|
258
|
+
*
|
|
259
|
+
* #3638: refused too (`conflict`, `environmentCheckpointRefusal`) when `next` changes the permission
|
|
260
|
+
* surface or the migrations against the version the environment serves (`environmentServedVersionIn`)
|
|
261
|
+
* and `acknowledge` does not acknowledge it. The caller judges the same before it uploads anything;
|
|
262
|
+
* this is the record's own judgement, in the transaction that moves what the environment serves.
|
|
263
|
+
*/
|
|
264
|
+
export function setEnvironmentServingIn(sql, input, next, expected,
|
|
265
|
+
/** The serve's claim (`claimEnvironmentServeIn`): the record lands only while it is still the one held. */
|
|
266
|
+
claim,
|
|
267
|
+
/** #3638: what this serve acknowledges, in this environment. */
|
|
268
|
+
acknowledge) {
|
|
269
|
+
const { tenantId, vertical, name } = input;
|
|
270
|
+
assertEnvironment(sql, input);
|
|
271
|
+
const before = rowServing(sql, input);
|
|
272
|
+
const preview = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name);
|
|
273
|
+
const scopeId = preview?.scope_id ?? null;
|
|
274
|
+
if (!sameServing(before, expected))
|
|
275
|
+
return { moved: false, before, scopeId };
|
|
276
|
+
if (claim !== undefined && claimOf(sql, input)?.claim !== claim)
|
|
277
|
+
return { moved: false, before, scopeId };
|
|
278
|
+
const served = environmentServedVersionIn(sql, input);
|
|
279
|
+
const incoming = checkpointSideIn(sql, next.versionId);
|
|
280
|
+
if (served !== null && incoming !== null) {
|
|
281
|
+
const refusal = environmentCheckpointRefusal(name, checkpointSideIn(sql, served), incoming, acknowledge);
|
|
282
|
+
if (refusal)
|
|
283
|
+
throw refusal;
|
|
284
|
+
}
|
|
285
|
+
if (before && before.ref !== next.ref) {
|
|
286
|
+
throw substratError('conflict', `the environment '${name}' serves from the script '${before.ref}', where its data lives: it cannot move to '${next.ref}'`);
|
|
287
|
+
}
|
|
288
|
+
const dropped = before?.doClasses.filter((c) => !next.doClasses.includes(c)) ?? [];
|
|
289
|
+
if (dropped.length) {
|
|
290
|
+
throw substratError('validation_failed', `a serving script's Durable Object classes only grow: ${dropped.join(', ')} would be dropped`);
|
|
291
|
+
}
|
|
292
|
+
sql.run(`UPDATE app_environments SET serving_ref = ?, serving_version_id = ?, serving_do_classes = ?, serving_migration_tag = ?
|
|
293
|
+
WHERE tenant_id = ? AND vertical = ? AND name = ?`, next.ref, next.versionId, JSON.stringify(next.doClasses), next.migrationTag, tenantId, vertical, name);
|
|
294
|
+
return { moved: true, before, scopeId };
|
|
295
|
+
}
|
|
296
|
+
const assertEnvironment = (sql, input) => {
|
|
297
|
+
if (input.name === PRODUCTION_ENVIRONMENT || !isEnvironmentTag(sql, input.tenantId, input.vertical, input.name)) {
|
|
298
|
+
throw substratError('not_found', `'${input.vertical}' has no environment '${input.name}' in tenant ${input.tenantId}`);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const claimOf = (sql, input) => {
|
|
302
|
+
const row = sql.all('SELECT serve_claim, serve_claimed_until FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', input.tenantId, input.vertical, input.name)[0];
|
|
303
|
+
return row?.serve_claim && row.serve_claimed_until ? { claim: row.serve_claim, until: row.serve_claimed_until } : null;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Take the environment's serve lease (#3530 step 4), so its serves run one at a time: a serve uploads
|
|
307
|
+
* onto the script before it records what it uploaded, and two at once could leave the script running
|
|
308
|
+
* the one whose record lost. True when `claim` now holds it: none was held, the one held has lapsed
|
|
309
|
+
* (`until` before `now`), or it is `claim`'s own (renewed). False while another live claim holds it.
|
|
310
|
+
* `not_found` for a name that is no environment.
|
|
311
|
+
*/
|
|
312
|
+
export function claimEnvironmentServeIn(sql, input, claim, at) {
|
|
313
|
+
assertEnvironment(sql, input);
|
|
314
|
+
const held = claimOf(sql, input);
|
|
315
|
+
if (held && held.claim !== claim && held.until > at.now)
|
|
316
|
+
return false;
|
|
317
|
+
sql.run('UPDATE app_environments SET serve_claim = ?, serve_claimed_until = ? WHERE tenant_id = ? AND vertical = ? AND name = ?', claim, at.until, input.tenantId, input.vertical, input.name);
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
/** Give the serve lease back. Only `claim`'s own: a lapsed claim taken over since is left to its holder. */
|
|
321
|
+
export function releaseEnvironmentServeIn(sql, input, claim) {
|
|
322
|
+
sql.run(`UPDATE app_environments SET serve_claim = NULL, serve_claimed_until = NULL
|
|
323
|
+
WHERE tenant_id = ? AND vertical = ? AND name = ? AND serve_claim = ?`, input.tenantId, input.vertical, input.name, claim);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Give a named environment connections of its own, or take that back (#3530 step 6), in the caller's
|
|
327
|
+
* one directory transaction with its admin row. Production's effects are not a choice, so naming it
|
|
328
|
+
* is `not_found` as every other door's is. `changed: false`, with nothing written, when the row
|
|
329
|
+
* already holds `effects`. Taking it back moves no connection: the environment's own stay where they
|
|
330
|
+
* are, and no door lets it use them until it is given them again.
|
|
331
|
+
*/
|
|
332
|
+
export function setEnvironmentEffectsIn(sql, input, effects) {
|
|
333
|
+
assertEnvironment(sql, input);
|
|
334
|
+
const { tenantId, vertical, name } = input;
|
|
335
|
+
const row = sql.all('SELECT effects FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', tenantId, vertical, name)[0];
|
|
336
|
+
const before = effectsOfColumn(row?.effects);
|
|
337
|
+
const scopeId = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name)?.scope_id ?? null;
|
|
338
|
+
if (before === effects)
|
|
339
|
+
return { changed: false, before, scopeId };
|
|
340
|
+
sql.run('UPDATE app_environments SET effects = ? WHERE tenant_id = ? AND vertical = ? AND name = ?', effects === 'none' ? null : effects, tenantId, vertical, name);
|
|
341
|
+
return { changed: true, before, scopeId };
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Which connections the scope's outside effects may go through (#3530 step 6): the one rule every
|
|
345
|
+
* connection door asks, decided here from the directory so a door cannot restate it wrongly.
|
|
346
|
+
*
|
|
347
|
+
* - `all`: an install (`isPrimaryScopeRow`), as today: the tenant's connections and its own.
|
|
348
|
+
* - `own`: the active, pinned preview that IS a named environment of its app (the scope that name
|
|
349
|
+
* resolves to, never another preview under the same slug), whose environment was given connections
|
|
350
|
+
* of its own. It reaches connections its own scope owns, and nothing else.
|
|
351
|
+
* - `none`: everything else, a scope that is not on record or is another tenant's included. A fork, a
|
|
352
|
+
* snapshot of an environment, an environment's preview while it is archived or expiring, and an
|
|
353
|
+
* environment nobody gave connections all read `none`, which is what they read before this rule.
|
|
354
|
+
*/
|
|
355
|
+
export function connectionReachIn(sql, tenantId, scopeId) {
|
|
356
|
+
return environmentReachIn(sql, tenantId, scopeId).reach;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* The environment whose broker the scope hands its messages to (D-83, #3639), or null when it hands
|
|
360
|
+
* off nothing. Decided by `connectionReachIn`'s one rule, so a scope sends through a broker exactly
|
|
361
|
+
* when it may cause outside effects at all:
|
|
362
|
+
*
|
|
363
|
+
* - an install (`all`) hands off to production's broker, `PRODUCTION_ENVIRONMENT`, as before;
|
|
364
|
+
* - the scope of a named environment given connections of its own (`own`) hands off to that
|
|
365
|
+
* environment's broker, never production's;
|
|
366
|
+
* - every other scope (a preview, a fork, a snapshot, an environment nobody gave connections, a scope
|
|
367
|
+
* not on record) hands off nothing, which is what it did before.
|
|
368
|
+
*/
|
|
369
|
+
export function deliveryEnvironmentIn(sql, tenantId, scopeId) {
|
|
370
|
+
const { reach, environment } = environmentReachIn(sql, tenantId, scopeId);
|
|
371
|
+
return reach === 'all' ? PRODUCTION_ENVIRONMENT : reach === 'own' ? environment : null;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The environment a scope belongs to, whatever it may do now (#3639): production for an install, a
|
|
375
|
+
* named environment's name for a preview whose slug names one of the app's environments (archived,
|
|
376
|
+
* expiring or given no effects alike), null for any other scope. It is what a scope's broker is found
|
|
377
|
+
* by after the fact, by subject erasure for one: unlike `deliveryEnvironmentIn` it does not follow the
|
|
378
|
+
* environment's effects, so a broker that took messages stays reachable once its environment is taken
|
|
379
|
+
* back to none, and the answer is read from the directory, never from what a process remembers.
|
|
380
|
+
*/
|
|
381
|
+
export function environmentOfScopeIn(sql, tenantId, scopeId) {
|
|
382
|
+
const row = sql.all('SELECT tenant_id, vertical, kind, slug, forked_from FROM scopes WHERE scope_id = ?', scopeId)[0];
|
|
383
|
+
if (!row || row.tenant_id !== tenantId)
|
|
384
|
+
return null;
|
|
385
|
+
if (isPrimaryScopeRow(row))
|
|
386
|
+
return PRODUCTION_ENVIRONMENT;
|
|
387
|
+
if (row.kind !== 'preview' || !row.vertical)
|
|
388
|
+
return null;
|
|
389
|
+
const name = environmentOfPreviewSlug(row.vertical, row.slug);
|
|
390
|
+
return name !== null && isEnvironmentTag(sql, tenantId, row.vertical, name) ? name : null;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* `deliveryEnvironmentIn`'s rule over a scope record and the directory's `connectionReach` for it, for
|
|
394
|
+
* a caller that holds those rather than the directory (the control plane's wake answer, #3639): an
|
|
395
|
+
* active install is production's, an active scope whose reach is `own` its environment's, every other
|
|
396
|
+
* scope none. `reach` is not read for an install, and a scope whose reach was not asked is none.
|
|
397
|
+
*/
|
|
398
|
+
export function deliveryEnvironmentOf(scope, reach) {
|
|
399
|
+
if (!scope?.vertical || scope.status !== 'active')
|
|
400
|
+
return null;
|
|
401
|
+
if (isPrimaryScope(scope))
|
|
402
|
+
return PRODUCTION_ENVIRONMENT;
|
|
403
|
+
return reach === 'own' ? environmentOfPreviewSlug(scope.vertical, scope.slug) : null;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The environment a preview's scope slug names, `previewScopeSlug`'s inverse: `staging` for
|
|
407
|
+
* `crm--staging` of `t-acme/crm`, or null for a slug that is not one of the app's previews.
|
|
408
|
+
*/
|
|
409
|
+
export function environmentOfPreviewSlug(vertical, slug) {
|
|
410
|
+
const prefix = previewScopeSlug(vertical, '');
|
|
411
|
+
return slug && slug.startsWith(prefix) && slug.length > prefix.length ? slug.slice(prefix.length) : null;
|
|
412
|
+
}
|
|
413
|
+
/** `connectionReachIn`'s rule, with the environment an `own` scope is the scope of. */
|
|
414
|
+
function environmentReachIn(sql, tenantId, scopeId) {
|
|
415
|
+
const none = { reach: 'none', environment: null };
|
|
416
|
+
const row = sql.all('SELECT tenant_id, vertical, kind, slug, forked_from, status, expires_at FROM scopes WHERE scope_id = ?', scopeId)[0];
|
|
417
|
+
if (!row || row.tenant_id !== tenantId)
|
|
418
|
+
return none;
|
|
419
|
+
if (isPrimaryScopeRow(row))
|
|
420
|
+
return { reach: 'all', environment: PRODUCTION_ENVIRONMENT };
|
|
421
|
+
if (row.kind !== 'preview' || row.status !== 'active' || row.expires_at !== null || !row.vertical || !row.slug)
|
|
422
|
+
return none;
|
|
423
|
+
const name = environmentOfPreviewSlug(row.vertical, row.slug);
|
|
424
|
+
if (name === null)
|
|
425
|
+
return none;
|
|
426
|
+
const env = sql.all('SELECT effects FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', tenantId, row.vertical, name)[0];
|
|
427
|
+
if (!env || effectsOfColumn(env.effects) !== 'own-connections')
|
|
428
|
+
return none;
|
|
429
|
+
return previewOf(liveScopesOf(sql, tenantId, row.vertical), row.vertical, name)?.scope_id === scopeId
|
|
430
|
+
? { reach: 'own', environment: name }
|
|
431
|
+
: none;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Whether a scope whose reach is `reach` may make its effects through `connection` (#3530 step 6). An
|
|
435
|
+
* install uses the tenant's connections and its own; an environment given connections of its own uses
|
|
436
|
+
* its own alone; nothing else uses any. Another scope's own connection is never usable.
|
|
437
|
+
*/
|
|
438
|
+
export function connectionUsableBy(reach, scopeId, connection) {
|
|
439
|
+
if (reach === 'none')
|
|
440
|
+
return false;
|
|
441
|
+
if (connection.ownerScopeId === scopeId)
|
|
442
|
+
return true;
|
|
443
|
+
return reach === 'all' && connection.ownerScopeId === null;
|
|
444
|
+
}
|
|
116
445
|
//# sourceMappingURL=app-environments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-environments.js","sourceRoot":"","sources":["../src/app-environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,aAAa,EAAoD,MAAM,yBAAyB,CAAC;AACnJ,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,GAAW,EAAU,EAAE,CAAC,GA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AAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,wFAAwF,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAEhI,CAAC;IACd,IAAI,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAC5E,OAAO,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,QAAQ,KAAK,OAAO;QACnG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE;QACrC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAsB,EACtB,OAAyB,EACzB,UAA2C;IAE3C,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACnC,IAAI,UAAU,CAAC,YAAY,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,KAAK,KAAK,KAAK,IAAI,UAAU,CAAC,YAAY,KAAK,IAAI,CAAC;AAC7D,CAAC"}
|
package/dist/broker-counts.d.ts
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* #3474 (rfc/broker-and-tenant-isolation.md §9.2, K-70): the delivery broker's EXACT counts, kept per
|
|
3
|
-
* UTC day in its own SQLite and shipped to the lake. Analytics Engine samples at volume, which is
|
|
4
|
-
* enough for trends and alarms (`broker-telemetry.ts`) and not for billing. These are counted in the
|
|
5
|
-
* same transaction as the decision they count, so a count is a fact about the store, never an
|
|
6
|
-
* estimate.
|
|
7
|
-
*
|
|
8
|
-
* **What is counted**, per (day, tenant, scope, channel, receiver, outcome): a message `received`
|
|
9
|
-
* (once, at its first acceptance; a duplicate handoff counts nothing; receiver `''`), and per
|
|
10
|
-
* receiver a delivery `delivered`, an attempt `retried` (a failure the broker will try again; a
|
|
11
|
-
* slow-down spends nothing and counts nothing), a delivery gone `dead`, a dead letter `resent` or
|
|
12
|
-
* `discarded` by a person, and one `expired` unresent. Never content: ids, the channel and the
|
|
13
|
-
* receiver's name.
|
|
14
|
-
*
|
|
15
|
-
* **Shipped, then bounded (K-70).** A row is shipped when its count moves past what the lake has: it
|
|
16
|
-
* carries its whole count, so the lake keeps a key's latest version (`BrokerLakeRow`, the directory's
|
|
17
|
-
* outbox shape, dataset `broker_count_days`). What was shipped is recorded as the count shipped, not
|
|
18
|
-
* as "shipped": a count that moved while the ship was in flight goes again. Shipping is at most
|
|
19
|
-
* every `BROKER_COUNT_SHIP_MS` (D-77's five minutes), from the broker's own alarm, so K-69 holds.
|
|
20
|
-
* A day is dropped once the lake has all of it and it is older than `BROKER_COUNT_KEEP_DAYS` (the
|
|
21
|
-
* current and the previous billing period, as the directory keeps meter days); a day never shipped,
|
|
22
|
-
* because no lake was ever bound, is dropped at `BROKER_COUNT_MAX_DAYS`, so an unbound broker is
|
|
23
|
-
* bounded too.
|
|
24
|
-
*
|
|
25
|
-
* Its table is step 5 of `broker-schema.ts`.
|
|
26
|
-
*/
|
|
27
1
|
import type { BrokerMessageKind, BrokerSql } from './delivery-broker.js';
|
|
28
2
|
/** What happened, as a count names it. */
|
|
29
3
|
export type BrokerCountOutcome = 'received' | 'delivered' | 'retried' | 'dead' | 'resent' | 'discarded' | 'expired';
|
|
@@ -87,7 +61,7 @@ export interface BrokerLakeRow {
|
|
|
87
61
|
kind: BrokerCountOutcome;
|
|
88
62
|
actor: null;
|
|
89
63
|
capturedAt: string;
|
|
90
|
-
/** The count, a JSON object text: `{ day, tenant_id, app, scope_id, channel, receiver, outcome, n }
|
|
64
|
+
/** The count, a JSON object text: `{ day, tenant_id, app, scope_id, channel, receiver, outcome, n }`, and a named environment's `environment` (#3639). */
|
|
91
65
|
row: string;
|
|
92
66
|
}
|
|
93
67
|
/**
|
|
@@ -98,11 +72,15 @@ export interface BrokerLakeRow {
|
|
|
98
72
|
export interface BrokerLakeSink {
|
|
99
73
|
ship(rows: BrokerLakeRow[]): Promise<void>;
|
|
100
74
|
}
|
|
101
|
-
/**
|
|
102
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The lake rows for some counts of one app's broker. A named environment's broker (#3639) adds its
|
|
77
|
+
* environment to the key and the row; production's rows are what they were, byte for byte, so a key
|
|
78
|
+
* the lake already holds keeps its meaning.
|
|
79
|
+
*/
|
|
80
|
+
export declare function brokerLakeRows(rows: readonly BrokerCountDay[], app: string, capturedAt: string, environment?: string): BrokerLakeRow[];
|
|
103
81
|
/**
|
|
104
82
|
* Ship one batch of what the lake does not have, and mark it. A sink that throws marks nothing: the
|
|
105
83
|
* rows go again at the next ship. Returns how many rows went.
|
|
106
84
|
*/
|
|
107
|
-
export declare function shipBrokerCounts(sql: BrokerSql, sink: BrokerLakeSink, app: string, now: number): Promise<number>;
|
|
85
|
+
export declare function shipBrokerCounts(sql: BrokerSql, sink: BrokerLakeSink, app: string, now: number, environment?: string): Promise<number>;
|
|
108
86
|
//# sourceMappingURL=broker-counts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-counts.d.ts","sourceRoot":"","sources":["../src/broker-counts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broker-counts.d.ts","sourceRoot":"","sources":["../src/broker-counts.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEzE,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAEpH,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAAmF,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qB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAGnE;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAInE;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,IAAI,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,0JAA0J;IAC1J,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE,CAoBtI;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAMjB"}
|
package/dist/broker-counts.js
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3474 (rfc/broker-and-tenant-isolation.md §9.2, K-70): the delivery broker's EXACT counts, kept per
|
|
3
|
+
* UTC day in its own SQLite and shipped to the lake. Analytics Engine samples at volume, which is
|
|
4
|
+
* enough for trends and alarms (`broker-telemetry.ts`) and not for billing. These are counted in the
|
|
5
|
+
* same transaction as the decision they count, so a count is a fact about the store, never an
|
|
6
|
+
* estimate.
|
|
7
|
+
*
|
|
8
|
+
* **What is counted**, per (day, tenant, scope, channel, receiver, outcome): a message `received`
|
|
9
|
+
* (once, at its first acceptance; a duplicate handoff counts nothing; receiver `''`), and per
|
|
10
|
+
* receiver a delivery `delivered`, an attempt `retried` (a failure the broker will try again; a
|
|
11
|
+
* slow-down spends nothing and counts nothing), a delivery gone `dead`, a dead letter `resent` or
|
|
12
|
+
* `discarded` by a person, and one `expired` unresent. Never content: ids, the channel and the
|
|
13
|
+
* receiver's name.
|
|
14
|
+
*
|
|
15
|
+
* **Shipped, then bounded (K-70).** A row is shipped when its count moves past what the lake has: it
|
|
16
|
+
* carries its whole count, so the lake keeps a key's latest version (`BrokerLakeRow`, the directory's
|
|
17
|
+
* outbox shape, dataset `broker_count_days`). What was shipped is recorded as the count shipped, not
|
|
18
|
+
* as "shipped": a count that moved while the ship was in flight goes again. Shipping is at most
|
|
19
|
+
* every `BROKER_COUNT_SHIP_MS` (D-77's five minutes), from the broker's own alarm, so K-69 holds.
|
|
20
|
+
* A day is dropped once the lake has all of it and it is older than `BROKER_COUNT_KEEP_DAYS` (the
|
|
21
|
+
* current and the previous billing period, as the directory keeps meter days); a day never shipped,
|
|
22
|
+
* because no lake was ever bound, is dropped at `BROKER_COUNT_MAX_DAYS`, so an unbound broker is
|
|
23
|
+
* bounded too.
|
|
24
|
+
*
|
|
25
|
+
* Its table is step 5 of `broker-schema.ts`.
|
|
26
|
+
*/
|
|
27
|
+
import { PRODUCTION_ENVIRONMENT } from '@substrat-run/contracts';
|
|
1
28
|
export const BROKER_COUNT_OUTCOMES = ['received', 'delivered', 'retried', 'dead', 'resent', 'discarded', 'expired'];
|
|
2
29
|
/**
|
|
3
30
|
* The Pipelines stream binding a broker ships its counts through, on the app's script. No binding, no
|
|
@@ -70,11 +97,18 @@ export function pruneBrokerCounts(sql, now) {
|
|
|
70
97
|
sql.run('DELETE FROM broker_count_days WHERE day < ? AND n = shipped_n', day(BROKER_COUNT_KEEP_DAYS));
|
|
71
98
|
sql.run('DELETE FROM broker_count_days WHERE day < ?', day(BROKER_COUNT_MAX_DAYS));
|
|
72
99
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The lake rows for some counts of one app's broker. A named environment's broker (#3639) adds its
|
|
102
|
+
* environment to the key and the row; production's rows are what they were, byte for byte, so a key
|
|
103
|
+
* the lake already holds keeps its meaning.
|
|
104
|
+
*/
|
|
105
|
+
export function brokerLakeRows(rows, app, capturedAt, environment) {
|
|
106
|
+
const named = environment && environment !== PRODUCTION_ENVIRONMENT ? environment : null;
|
|
75
107
|
return rows.map((r) => ({
|
|
76
108
|
dataset: 'broker_count_days',
|
|
77
|
-
rowKey: JSON.stringify(
|
|
109
|
+
rowKey: JSON.stringify(named === null
|
|
110
|
+
? [r.day, r.tenantId, app, r.scopeId, r.channel, r.receiver, r.outcome]
|
|
111
|
+
: [r.day, r.tenantId, app, named, r.scopeId, r.channel, r.receiver, r.outcome]),
|
|
78
112
|
tenantId: r.tenantId,
|
|
79
113
|
scopeId: r.scopeId,
|
|
80
114
|
at: r.day,
|
|
@@ -82,7 +116,8 @@ export function brokerLakeRows(rows, app, capturedAt) {
|
|
|
82
116
|
actor: null,
|
|
83
117
|
capturedAt,
|
|
84
118
|
row: JSON.stringify({
|
|
85
|
-
day: r.day, tenant_id: r.tenantId, app,
|
|
119
|
+
day: r.day, tenant_id: r.tenantId, app, ...(named === null ? {} : { environment: named }), scope_id: r.scopeId, channel: r.channel,
|
|
120
|
+
receiver: r.receiver, outcome: r.outcome, n: r.n,
|
|
86
121
|
}),
|
|
87
122
|
}));
|
|
88
123
|
}
|
|
@@ -90,11 +125,11 @@ export function brokerLakeRows(rows, app, capturedAt) {
|
|
|
90
125
|
* Ship one batch of what the lake does not have, and mark it. A sink that throws marks nothing: the
|
|
91
126
|
* rows go again at the next ship. Returns how many rows went.
|
|
92
127
|
*/
|
|
93
|
-
export async function shipBrokerCounts(sql, sink, app, now) {
|
|
128
|
+
export async function shipBrokerCounts(sql, sink, app, now, environment) {
|
|
94
129
|
const rows = unshippedBrokerCounts(sql);
|
|
95
130
|
if (rows.length === 0)
|
|
96
131
|
return 0;
|
|
97
|
-
await sink.ship(brokerLakeRows(rows, app, new Date(now).toISOString()));
|
|
132
|
+
await sink.ship(brokerLakeRows(rows, app, new Date(now).toISOString(), environment));
|
|
98
133
|
markBrokerCountsShipped(sql, rows);
|
|
99
134
|
return rows.length;
|
|
100
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-counts.js","sourceRoot":"","sources":["../src/broker-counts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broker-counts.js","sourceRoot":"","sources":["../src/broker-counts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAMjE,MAAM,CAAC,MAAM,qBAAqB,GAAkC,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAEnJ;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAE1D,uFAAuF;AACvF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,MAAM,CAAC;AAC/C,yFAAyF;AACzF,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAoB3C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAU,EAAU,EAAE,C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,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SACjD,CAAC;KACH,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAc,EACd,IAAoB,EACpB,GAAW,EACX,GAAW,EACX,WAAoB;IAEpB,MAAM,IAAI,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAChC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IACrF,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
|
package/dist/broker-shadow.d.ts
CHANGED
|
@@ -185,6 +185,8 @@ export interface UnreadScope {
|
|
|
185
185
|
export interface DeliveryComparison {
|
|
186
186
|
tenantId: string;
|
|
187
187
|
app: string;
|
|
188
|
+
/** The environment whose broker was compared (#3639): absent for production's. */
|
|
189
|
+
environment?: string;
|
|
188
190
|
/** Epoch ms it was read, and the window's end as an instant: younger messages are in flight. */
|
|
189
191
|
at: number;
|
|
190
192
|
before: string;
|
|
@@ -211,6 +213,7 @@ export type WitnessReader = (scope: ShadowScope, before: string, limit: number)
|
|
|
211
213
|
export declare function compareDeliveries(recorder: ShadowRecorder, witness: WitnessReader, ids: {
|
|
212
214
|
tenantId: string;
|
|
213
215
|
app: string;
|
|
216
|
+
environment?: string;
|
|
214
217
|
}, opts: {
|
|
215
218
|
now: number;
|
|
216
219
|
graceMs?: number;
|