@toa.io/extensions.cadence 1.0.0-alpha.284 → 1.0.0-alpha.287
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/CHANGELOG.md +3 -3
- package/LICENSE +22 -0
- package/components/cadence.metronome/manifest.toa.yaml +22 -28
- package/components/cadence.metronome/migrations/0001-system-properties.yaml +14 -0
- package/components/cadence.metronome/migrations/0002-indexes.yaml +5 -0
- package/components/cadence.metronome/migrations/0003-pending-index.yaml +16 -0
- package/components/cadence.metronome/migrations/0004-retention.yaml +15 -0
- package/components/cadence.metronome/operations/delay.js +1 -1
- package/components/cadence.metronome/operations/settle.js +8 -4
- package/components/cadence.metronome/types/toa.d.ts +5 -5
- package/package.json +6 -5
- package/readme.md +35 -21
- package/schemas/declaration.cos.yaml +0 -1
- package/source/Aspect.ts +19 -10
- package/source/Composition.ts +4 -4
- package/source/Dispatcher.test.ts +240 -32
- package/source/Dispatcher.ts +145 -32
- package/source/Factory.ts +13 -10
- package/source/Local.ts +5 -4
- package/source/Pulse.test.ts +48 -19
- package/source/Pulse.ts +30 -21
- package/source/const.ts +7 -1
- package/source/context.ts +2 -2
- package/source/deployment.ts +10 -5
- package/source/manifest.test.ts +9 -6
- package/source/manifest.ts +24 -11
- package/transpiled/Aspect.d.ts +0 -1
- package/transpiled/Aspect.js +11 -5
- package/transpiled/Aspect.js.map +1 -1
- package/transpiled/Composition.js.map +1 -1
- package/transpiled/Dispatcher.d.ts +22 -4
- package/transpiled/Dispatcher.js +111 -18
- package/transpiled/Dispatcher.js.map +1 -1
- package/transpiled/Factory.d.ts +1 -1
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Local.d.ts +2 -1
- package/transpiled/Local.js.map +1 -1
- package/transpiled/Pulse.d.ts +2 -1
- package/transpiled/Pulse.js +14 -5
- package/transpiled/Pulse.js.map +1 -1
- package/transpiled/const.d.ts +6 -0
- package/transpiled/const.js +6 -0
- package/transpiled/const.js.map +1 -1
- package/transpiled/context.d.ts +1 -1
- package/transpiled/deployment.js +5 -2
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/manifest.js +6 -3
- package/transpiled/manifest.js.map +1 -1
- package/tsconfig.tsbuildinfo +1 -0
package/transpiled/Dispatcher.js
CHANGED
|
@@ -5,9 +5,10 @@ import { BATCH, DISCRETENESS, LANES, number } from './const.js';
|
|
|
5
5
|
* Makes the calls that were put off.
|
|
6
6
|
*
|
|
7
7
|
* Two tiers, which is what a store polled rarely and a call due to the second need between
|
|
8
|
-
* them: the rows are the record, and one scan primes the next
|
|
9
|
-
* A crash loses the timers and nothing else — the next scan reads what is overdue
|
|
10
|
-
* what is upcoming, so a dispatcher that died mid-interval costs a delay and not a
|
|
8
|
+
* them: the rows are the record, and one scan primes the next two intervals of them into
|
|
9
|
+
* timers. A crash loses the timers and nothing else — the next scan reads what is overdue
|
|
10
|
+
* along with what is upcoming, so a dispatcher that died mid-interval costs a delay and not a
|
|
11
|
+
* call.
|
|
11
12
|
*
|
|
12
13
|
* Partitioned by lane exactly as the outbox is, so every replica scans and dispatches its own
|
|
13
14
|
* share of every interval rather than taking turns at whole ones.
|
|
@@ -28,6 +29,8 @@ export class Dispatcher extends Connector {
|
|
|
28
29
|
off;
|
|
29
30
|
scanning = false;
|
|
30
31
|
closing = false;
|
|
32
|
+
/** when the scan that is running started, so a tick that finds it can say how long */
|
|
33
|
+
started = 0;
|
|
31
34
|
constructor(metronome, resolve, atom) {
|
|
32
35
|
super();
|
|
33
36
|
this.metronome = metronome;
|
|
@@ -38,10 +41,14 @@ export class Dispatcher extends Connector {
|
|
|
38
41
|
this.depends(atom);
|
|
39
42
|
}
|
|
40
43
|
async open() {
|
|
41
|
-
this.timer = setInterval(() => {
|
|
44
|
+
this.timer = setInterval(() => {
|
|
45
|
+
this.tick();
|
|
46
|
+
}, this.discreteness);
|
|
42
47
|
this.timer.unref();
|
|
43
48
|
// a lane changing hands is when its rows become this replica's, or stop being
|
|
44
|
-
this.off = this.atom.onassigned(() => {
|
|
49
|
+
this.off = this.atom.onassigned(() => {
|
|
50
|
+
this.adopt();
|
|
51
|
+
});
|
|
45
52
|
}
|
|
46
53
|
async close() {
|
|
47
54
|
this.closing = true;
|
|
@@ -54,12 +61,34 @@ export class Dispatcher extends Connector {
|
|
|
54
61
|
}
|
|
55
62
|
/** One scan at a time: a slow one must not have another started underneath it. */
|
|
56
63
|
tick() {
|
|
57
|
-
if (this.
|
|
64
|
+
if (this.closing)
|
|
65
|
+
return;
|
|
66
|
+
/*
|
|
67
|
+
* Skipped, and said so. The guard itself is right — a second scan on top of one that has
|
|
68
|
+
* not returned only makes it worse — but a pass that outlives its interval takes every
|
|
69
|
+
* pass after it with it, and nothing is dispatched at all while that lasts. Silently, it
|
|
70
|
+
* is a dispatcher that stops dispatching in a deployment that ran for months.
|
|
71
|
+
*/
|
|
72
|
+
if (this.scanning) {
|
|
73
|
+
const running = Date.now() - this.started;
|
|
74
|
+
const details = { running, discreteness: this.discreteness };
|
|
75
|
+
const message = 'Delayed calls scan has not returned, so this pass is skipped';
|
|
76
|
+
// past a few intervals it is not a slow pass but a stuck one
|
|
77
|
+
if (running > STALLED * this.discreteness)
|
|
78
|
+
console.error(message, details);
|
|
79
|
+
else
|
|
80
|
+
console.warn(message, details);
|
|
58
81
|
return;
|
|
82
|
+
}
|
|
59
83
|
this.scanning = true;
|
|
84
|
+
this.started = Date.now();
|
|
60
85
|
void this.scan()
|
|
61
|
-
.catch((error) => {
|
|
62
|
-
.
|
|
86
|
+
.catch((error) => {
|
|
87
|
+
console.error('Delayed calls scan failed', { error });
|
|
88
|
+
})
|
|
89
|
+
.finally(() => {
|
|
90
|
+
this.scanning = false;
|
|
91
|
+
});
|
|
63
92
|
}
|
|
64
93
|
/**
|
|
65
94
|
* What this replica owns has changed. Timers for lanes it no longer holds are dropped —
|
|
@@ -82,22 +111,64 @@ export class Dispatcher extends Connector {
|
|
|
82
111
|
}
|
|
83
112
|
}
|
|
84
113
|
async scan() {
|
|
114
|
+
// ahead of the claim, because settling needs none: the rows are ones this replica has
|
|
115
|
+
// already called, and one left live is one the next owner of its lane calls again
|
|
116
|
+
await this.settle();
|
|
85
117
|
const lanes = this.atom.slots(LANES);
|
|
86
118
|
if (lanes === null || lanes.length === 0)
|
|
87
119
|
return;
|
|
88
|
-
await this.settle();
|
|
89
120
|
const now = Date.now();
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
/*
|
|
122
|
+
* Two intervals, so that consecutive passes overlap by one whole one. Reaching exactly as
|
|
123
|
+
* far as the next pass leaves a sliver beyond the horizon that the next pass reads already
|
|
124
|
+
* overdue — the width of the drift between the two, which a row with a tight `overdue`
|
|
125
|
+
* does not survive. The overlap absorbs that, a settle that ran long, a tick skipped
|
|
126
|
+
* outright, and the clock skew between the replica that wrote `due` and this one.
|
|
127
|
+
*
|
|
128
|
+
* Reaching further costs nothing a cancellation would pay for, because what is armed is
|
|
129
|
+
* given up again the moment a scan stops reading it — see `forget`.
|
|
130
|
+
*/
|
|
131
|
+
const until = now + 2 * this.discreteness;
|
|
132
|
+
const rows = (await this.metronome.invoke('enumerate', {
|
|
92
133
|
query: {
|
|
93
|
-
// a
|
|
94
|
-
|
|
134
|
+
// expiry is not a criterion: a row nobody reads is a row nobody settles, and it would
|
|
135
|
+
// stay live for good. It is read, and settled without the call being made
|
|
136
|
+
criteria: `lane=in=(${lanes.join(',')});due<${until}`,
|
|
95
137
|
sort: ['due:asc'],
|
|
96
138
|
limit: BATCH
|
|
97
139
|
}
|
|
98
|
-
});
|
|
140
|
+
}));
|
|
141
|
+
// the horizon is truncated to the last row of a full batch, and everything past it arrives
|
|
142
|
+
// on a later pass already overdue. Where this is logged, the batch is too small for the rate
|
|
143
|
+
const truncated = rows.length === BATCH;
|
|
144
|
+
if (truncated)
|
|
145
|
+
console.warn('Delayed calls scan filled its batch', { limit: BATCH, lanes: lanes.length });
|
|
99
146
|
for (const row of rows)
|
|
100
147
|
this.arm(row);
|
|
148
|
+
if (!truncated)
|
|
149
|
+
this.forget(new Set(rows.map((row) => row.id)));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Gives up what the store no longer answers with. A scan reads everything still owed in the
|
|
153
|
+
* lanes this replica holds, so a row it armed before and does not read now is one nothing
|
|
154
|
+
* owes any more — cancelled, most of the time — and a timer left for it makes the call
|
|
155
|
+
* regardless.
|
|
156
|
+
*
|
|
157
|
+
* This is what lets a scan reach further ahead than the next one without a cancellation
|
|
158
|
+
* becoming any less reliable: a row is held only for as long as the store keeps saying it is
|
|
159
|
+
* owed, so what bounds cancelling is the period between passes and not how far one reaches.
|
|
160
|
+
*
|
|
161
|
+
* Two things are not evidence of a cancellation. A batch filled to its limit is a read that
|
|
162
|
+
* was cut short, and says nothing about what it did not reach. And a call already on its way
|
|
163
|
+
* is settled by its own path rather than by what a scan reads.
|
|
164
|
+
*/
|
|
165
|
+
forget(read) {
|
|
166
|
+
for (const [id, { timer }] of this.armed) {
|
|
167
|
+
if (read.has(id) || this.called.has(id))
|
|
168
|
+
continue;
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
this.armed.delete(id);
|
|
171
|
+
}
|
|
101
172
|
}
|
|
102
173
|
/**
|
|
103
174
|
* A row already armed is left alone: a scan reads what it read before, because a row stays
|
|
@@ -106,7 +177,20 @@ export class Dispatcher extends Connector {
|
|
|
106
177
|
arm(row) {
|
|
107
178
|
if (this.armed.has(row.id) || this.called.has(row.id))
|
|
108
179
|
return;
|
|
109
|
-
const
|
|
180
|
+
const now = Date.now();
|
|
181
|
+
/*
|
|
182
|
+
* Past the bound its caller gave it, so the call is not made — and the row is settled all
|
|
183
|
+
* the same, silently, because an expired call is not an event anything sees. Left unread
|
|
184
|
+
* it would never be settled either: a row nothing will ever act on, sitting in the
|
|
185
|
+
* collection and in front of every scan, for good.
|
|
186
|
+
*/
|
|
187
|
+
if (row.expires <= now) {
|
|
188
|
+
this.called.add(row.id);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const timer = setTimeout(() => {
|
|
192
|
+
void this.dispatch(row);
|
|
193
|
+
}, Math.max(row.due - now, 0));
|
|
110
194
|
timer.unref();
|
|
111
195
|
this.armed.set(row.id, { timer, lane: row.lane });
|
|
112
196
|
}
|
|
@@ -136,13 +220,20 @@ export class Dispatcher extends Connector {
|
|
|
136
220
|
*
|
|
137
221
|
* Skipped, as a pulse skips: reported, and the row settled on the attempt either way.
|
|
138
222
|
*/
|
|
139
|
-
await local
|
|
223
|
+
await local
|
|
224
|
+
.invoke(endpoint, { input: null, ...row.request, task: true })
|
|
140
225
|
.catch((error) => {
|
|
141
|
-
console.error('Delayed call failed', {
|
|
226
|
+
console.error('Delayed call failed', {
|
|
227
|
+
endpoint: row.endpoint,
|
|
228
|
+
id: row.id,
|
|
229
|
+
error
|
|
230
|
+
});
|
|
142
231
|
})
|
|
143
232
|
// held for as long as the call is, so `armed` answers what this replica has in hand
|
|
144
233
|
// rather than what it has a timer for
|
|
145
|
-
.finally(() => {
|
|
234
|
+
.finally(() => {
|
|
235
|
+
this.armed.delete(row.id);
|
|
236
|
+
});
|
|
146
237
|
}
|
|
147
238
|
/**
|
|
148
239
|
* A remote is resolved once per target and held: it opens a connection, and one nothing
|
|
@@ -167,4 +258,6 @@ export class Dispatcher extends Connector {
|
|
|
167
258
|
this.called.delete(id);
|
|
168
259
|
}
|
|
169
260
|
}
|
|
261
|
+
/** intervals a scan may run for before it is a stuck pass rather than a slow one */
|
|
262
|
+
const STALLED = 5;
|
|
170
263
|
//# sourceMappingURL=Dispatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dispatcher.js","sourceRoot":"","sources":["../source/Dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MA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,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAEtE,0FAA0F;QAC1F,KAAK,MAAM,EAAE,IAAI,GAAG;YAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF;AAmBD,oFAAoF;AACpF,MAAM,OAAO,GAAG,CAAC,CAAA"}
|
package/transpiled/Factory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connector, Locator } from '@toa.io/core';
|
|
2
|
-
import type { extensions } from '@toa.io/core';
|
|
2
|
+
import type { extensions } from '@toa.io/core/types';
|
|
3
3
|
export declare class Factory implements extensions.Factory {
|
|
4
4
|
private readonly host;
|
|
5
5
|
/** one per component, however much of this extension calls through it */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAIlC,MAAM,OAAO,OAAO;IACD,IAAI,CAAM;IAE3B,yEAAyE;IACxD,MAAM,GAA0B,EAAE,CAAA;IAEnD,
|
|
1
|
+
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA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K,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;QAEjF,OAAO,MAAM,CAAA;IACf,CAAC;IAED,8EAA8E;IACvE,MAAM,CAAC,OAAgB;QAC5B,IAAI,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAA;QAE5B,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAEO,SAAS;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;IACtD,CAAC;IAEO,KAAK,CAAC,OAAgB;QAC5B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACpE,CAAC;CACF;AAED,4FAA4F;AAC5F,SAAS,IAAI,CAAC,OAAgB;IAC5B,OAAO,OAAO,CAAC,SAAS,KAAK,SAAS,CAAA;AACxC,CAAC"}
|
package/transpiled/Local.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Connector } from '@toa.io/core';
|
|
2
2
|
import type { Host } from './Factory.js';
|
|
3
|
-
import type { Locator
|
|
3
|
+
import type { Locator } from '@toa.io/core';
|
|
4
|
+
import type { Reply, Request } from '@toa.io/core/types';
|
|
4
5
|
/**
|
|
5
6
|
* The component a tenant belongs to, as something to call.
|
|
6
7
|
*
|
package/transpiled/Local.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Local.js","sourceRoot":"","sources":["../source/Local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Local.js","sourceRoot":"","sources":["../source/Local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAKxC;;;;;;GAMG;AACH,MAAM,OAAO,KAAM,SAAQ,SAAS;IACjB,IAAI,CAAM;IACV,OAAO,CAAS;IACzB,MAAM,CAAkB;IAEhC,YAAmB,IAAU,EAAE,OAAgB;QAC7C,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,OAAgB;QACpD,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAA;QAE7B,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAEnD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEpB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;QAEtB,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
package/transpiled/Pulse.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Connector } from '@toa.io/core';
|
|
2
2
|
import type { Local } from './Local.js';
|
|
3
|
-
import type { Locator
|
|
3
|
+
import type { Locator } from '@toa.io/core';
|
|
4
|
+
import type { atomicity } from '@toa.io/core/types';
|
|
4
5
|
/**
|
|
5
6
|
* A recurring call to an operation of its own component, on the cadence its manifest states.
|
|
6
7
|
*
|
package/transpiled/Pulse.js
CHANGED
|
@@ -57,7 +57,7 @@ export class Pulse extends Connector {
|
|
|
57
57
|
* for a long cycle cut finely. It is evaluated once per interval, where this costs nothing.
|
|
58
58
|
*/
|
|
59
59
|
ordinal(now) {
|
|
60
|
-
return Number(BigInt(now) * BigInt(this.n) / BigInt(this.cycle));
|
|
60
|
+
return Number((BigInt(now) * BigInt(this.n)) / BigInt(this.cycle));
|
|
61
61
|
}
|
|
62
62
|
/** Which of the cycle's intervals `now` falls in. */
|
|
63
63
|
index(now) {
|
|
@@ -112,12 +112,18 @@ export class Pulse extends Connector {
|
|
|
112
112
|
*/
|
|
113
113
|
async fire(i) {
|
|
114
114
|
if (this.firing !== undefined) {
|
|
115
|
-
console.warn('Pulse skipped: the previous call has not returned', {
|
|
115
|
+
console.warn('Pulse skipped: the previous call has not returned', {
|
|
116
|
+
pulse: this.label,
|
|
117
|
+
interval: i
|
|
118
|
+
});
|
|
116
119
|
return;
|
|
117
120
|
}
|
|
118
121
|
const owned = this.atom.slots(this.n);
|
|
119
122
|
if (owned === null) {
|
|
120
|
-
console.warn('Pulse skipped: this replica owns nothing', {
|
|
123
|
+
console.warn('Pulse skipped: this replica owns nothing', {
|
|
124
|
+
pulse: this.label,
|
|
125
|
+
interval: i
|
|
126
|
+
});
|
|
121
127
|
return;
|
|
122
128
|
}
|
|
123
129
|
if (!owned.includes(i))
|
|
@@ -129,11 +135,14 @@ export class Pulse extends Connector {
|
|
|
129
135
|
* only wanted an operation called every hour. So the interval is skipped: it is reported,
|
|
130
136
|
* and the next one is called as though it had not happened.
|
|
131
137
|
*/
|
|
132
|
-
const firing = console
|
|
138
|
+
const firing = console
|
|
139
|
+
.span(this.options, async () => await this.local.invoke(this.endpoint, { input: { n: this.n, i } }))
|
|
133
140
|
.catch((error) => {
|
|
134
141
|
console.error('Pulse failed', { pulse: this.label, interval: i, error });
|
|
135
142
|
})
|
|
136
|
-
.finally(() => {
|
|
143
|
+
.finally(() => {
|
|
144
|
+
this.firing = undefined;
|
|
145
|
+
});
|
|
137
146
|
this.firing = firing;
|
|
138
147
|
await firing;
|
|
139
148
|
}
|
package/transpiled/Pulse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pulse.js","sourceRoot":"","sources":["../source/Pulse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Pulse.js","sourceRoot":"","sources":["../source/Pulse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAMxC;;;;;;;;GAQG;AACH,MAAM,OAAO,KAAM,SAAQ,SAAS;IACjB,QAAQ,CAAQ;IAChB,KAAK,CAAQ;IAE9B,yCAAyC;IACxB,KAAK,CAAQ;IAE9B,wCAAwC;IACvB,CAAC,CAAQ;IAET,KAAK,CAAO;IACZ,IAAI,CAAgB;IAErC,+BAA+B;IACd,OAAO,CAAa;IAErC;;;;OAIG;IACK,KAAK,GAAG,CAAC,CAAA;IAET,KAAK,CAAiB;IAE9B,2CAA2C;IACnC,MAAM,CAAmB;IAEzB,OAAO,GAAG,KAAK,CAAA;IAEvB,YAAmB,UAAsB,EAAE,KAAY,EAAE,IAAoB;QAC3E,KAAK,EAAE,CAAA;QAEP,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;QAE1D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,GAAG,OAAO,CAAC,EAAE,IAAI,QAAQ,EAAE,CAAA;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;QACzB,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;QAElB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,IAAI,CAAC,OAAO,CAAC,KAAK,CA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;AACzF,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAE7B,uDAAuD;AACvD,MAAM,KAAK,GAAG,MAAM,CAAA"}
|
package/transpiled/const.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export declare const COMPONENT = "metronome";
|
|
|
5
5
|
* Constant, never configuration: a row carries its lane, so lowering this would leave rows in
|
|
6
6
|
* lanes nobody reads any more. It is also the ceiling on replicas dispatching, and a power of
|
|
7
7
|
* two so that the common replica counts divide evenly. The outbox says the same of its own.
|
|
8
|
+
*
|
|
9
|
+
* A scan asks for its lanes as a set and sorts on `due`, which is the index's second key, so
|
|
10
|
+
* the plan that serves it explodes the set into one scan per lane and merges them in order.
|
|
11
|
+
* MongoDB stops exploding past `internalQueryMaxScansToExplode`, 200 by default, and falls
|
|
12
|
+
* back to sorting the whole result in memory — so this staying well under that is not
|
|
13
|
+
* incidental.
|
|
8
14
|
*/
|
|
9
15
|
export declare const LANES = 128;
|
|
10
16
|
/** seconds between passes over the calls waiting to be made, and how far ahead each reaches */
|
package/transpiled/const.js
CHANGED
|
@@ -5,6 +5,12 @@ export const COMPONENT = 'metronome';
|
|
|
5
5
|
* Constant, never configuration: a row carries its lane, so lowering this would leave rows in
|
|
6
6
|
* lanes nobody reads any more. It is also the ceiling on replicas dispatching, and a power of
|
|
7
7
|
* two so that the common replica counts divide evenly. The outbox says the same of its own.
|
|
8
|
+
*
|
|
9
|
+
* A scan asks for its lanes as a set and sorts on `due`, which is the index's second key, so
|
|
10
|
+
* the plan that serves it explodes the set into one scan per lane and merges them in order.
|
|
11
|
+
* MongoDB stops exploding past `internalQueryMaxScansToExplode`, 200 by default, and falls
|
|
12
|
+
* back to sorting the whole result in memory — so this staying well under that is not
|
|
13
|
+
* incidental.
|
|
8
14
|
*/
|
|
9
15
|
export const LANES = 128;
|
|
10
16
|
/** seconds between passes over the calls waiting to be made, and how far ahead each reaches */
|
package/transpiled/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../source/const.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAEpC
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../source/const.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAEpC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;AAExB,+FAA+F;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAE9B,gCAAgC;AAChC,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;AAExB,oFAAoF;AACpF,MAAM,UAAU,MAAM,CAAC,QAAgB,EAAE,QAAgB;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IAE3C,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAA;AAC7D,CAAC"}
|
package/transpiled/context.d.ts
CHANGED
package/transpiled/deployment.js
CHANGED
|
@@ -11,11 +11,14 @@ export function deployment(_, annotation) {
|
|
|
11
11
|
// stated in seconds and carried in milliseconds, so that what an application writes is what
|
|
12
12
|
// the rest of a manifest is written in
|
|
13
13
|
const discreteness = (annotation?.discreteness ?? DISCRETENESS) * 1000;
|
|
14
|
-
const variables = [
|
|
14
|
+
const variables = [
|
|
15
|
+
{ name: 'TOA_CADENCE_DISCRETENESS', value: String(discreteness) }
|
|
16
|
+
];
|
|
15
17
|
const service = {
|
|
16
18
|
group: NAMESPACE,
|
|
17
19
|
name: 'metronome',
|
|
18
|
-
version: JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
|
|
20
|
+
version: JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
|
|
21
|
+
.version,
|
|
19
22
|
components: components().labels,
|
|
20
23
|
variables
|
|
21
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAIvC;;;GAGG;AACH,MAAM,UAAU,UAAU,
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAIvC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,CAAU,EAAE,UAA8B;IACnE,OAAO,CAAC,UAAU,CAAC,QAAQ,CACzB,UAAU,IAAI,IAAI,EAClB,4BAA4B,CAC7B,CAAA;IAED,4FAA4F;IAC5F,uCAAuC;IACvC,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,YAAY,IAAI,YAAY,CAAC,GAAG,IAAI,CAAA;IACtE,MAAM,SAAS,GAAe;QAC5B,EAAE,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE;KAClE,CAAA;IAED,MAAM,OAAO,GAAY;QACvB,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;aACnF,OAAO;QACV,UAAU,EAAE,UAAU,EAAE,CAAC,MAAM;QAC/B,SAAS;KACV,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAA;AAChC,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAA"}
|
package/transpiled/manifest.js
CHANGED
|
@@ -9,7 +9,6 @@ import * as schemas from './schemas.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export function manifest(declaration, component) {
|
|
11
11
|
const normalized = expand(declaration);
|
|
12
|
-
// `intervals` is defaulted by the schema, so the declaration is only whole after this
|
|
13
12
|
schemas.declaration.validate(normalized, 'Invalid cadence declaration');
|
|
14
13
|
for (const [endpoint, pulse] of Object.entries(normalized)) {
|
|
15
14
|
const operation = component.operations?.[endpoint];
|
|
@@ -28,8 +27,12 @@ export function manifest(declaration, component) {
|
|
|
28
27
|
function expand(declaration) {
|
|
29
28
|
if (declaration === null || declaration === undefined)
|
|
30
29
|
return {};
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// a cycle nothing splits is one interval, which is what the shorthand declares
|
|
31
|
+
return Object.fromEntries(Object.entries(declaration).map(([endpoint, pulse]) => {
|
|
32
|
+
const declared = typeof pulse === 'number' ? { cycle: pulse } : { ...pulse };
|
|
33
|
+
declared.intervals ??= 1;
|
|
34
|
+
return [endpoint, declared];
|
|
35
|
+
}));
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
38
|
* The types a receiver may refer to. An operation that produces no side effects has nothing to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../source/manifest.ts"],"names":[],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