@toa.io/core 1.0.0-alpha.305 → 1.0.0-alpha.308
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/package.json +2 -2
- package/transpiled/component.js +14 -1
- package/transpiled/component.js.map +1 -1
- package/transpiled/composition.d.ts +1 -1
- package/transpiled/composition.js +1 -4
- package/transpiled/composition.js.map +1 -1
- package/transpiled/connector.d.ts +17 -0
- package/transpiled/connector.js +55 -0
- package/transpiled/connector.js.map +1 -1
- package/transpiled/contract/component.d.ts +24 -0
- package/transpiled/contract/component.js +48 -0
- package/transpiled/contract/component.js.map +1 -0
- package/transpiled/contract/index.d.ts +1 -0
- package/transpiled/contract/index.js +1 -0
- package/transpiled/contract/index.js.map +1 -1
- package/transpiled/deliveries.d.ts +22 -0
- package/transpiled/deliveries.js +31 -0
- package/transpiled/deliveries.js.map +1 -0
- package/transpiled/exceptions.d.ts +12 -3
- package/transpiled/exceptions.js +20 -5
- package/transpiled/exceptions.js.map +1 -1
- package/transpiled/gate.d.ts +40 -0
- package/transpiled/gate.js +84 -0
- package/transpiled/gate.js.map +1 -0
- package/transpiled/halting.d.ts +16 -0
- package/transpiled/halting.js +25 -0
- package/transpiled/halting.js.map +1 -0
- package/transpiled/index.d.ts +4 -2
- package/transpiled/index.js +3 -2
- package/transpiled/index.js.map +1 -1
- package/transpiled/types/atomicity.d.ts +3 -1
- package/transpiled/types/bridges.d.ts +2 -0
- package/transpiled/types/extensions.d.ts +25 -1
- package/transpiled/discovery.d.ts +0 -19
- package/transpiled/discovery.js +0 -52
- package/transpiled/discovery.js.map +0 -1
- package/transpiled/exposition.d.ts +0 -18
- package/transpiled/exposition.js +0 -18
- package/transpiled/exposition.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.308",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa Core",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"openspan": "1.0.0-alpha.305",
|
|
46
46
|
"uuid": "14.0.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "66eb0d54032f60e6ead9e13fd9e21fb60c611277"
|
|
49
49
|
}
|
package/transpiled/component.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { console, current, decode, run } from 'openspan';
|
|
2
2
|
import { Connector } from './connector.js';
|
|
3
|
-
import { EndpointException, names, permanent } from './exceptions.js';
|
|
3
|
+
import { DisposedException, EndpointException, names, permanent } from './exceptions.js';
|
|
4
4
|
import * as measure from './measurements.js';
|
|
5
5
|
import * as trail from './trail.js';
|
|
6
6
|
/** The code a declared error refuses with, which its manifest bounds. */
|
|
@@ -22,6 +22,19 @@ export class Component extends Connector {
|
|
|
22
22
|
Object.values(operations).forEach((operation) => this.depends(operation));
|
|
23
23
|
}
|
|
24
24
|
async invoke(endpoint, request, options) {
|
|
25
|
+
/*
|
|
26
|
+
* A component that has been taken down refuses to work. What reaches it here is something
|
|
27
|
+
* the component started and did not stop — an interval, a watcher, a promise nobody
|
|
28
|
+
* awaited — calling through a context whose tree is gone, and a resume builds another tree
|
|
29
|
+
* rather than reviving this one, so it is never coming back.
|
|
30
|
+
*
|
|
31
|
+
* The client side is left alone deliberately: a `Remote` is a client to a queue rather than
|
|
32
|
+
* to an instance of anything, so its being taken down says nothing about whether what it
|
|
33
|
+
* calls is there.
|
|
34
|
+
*/
|
|
35
|
+
if (this.disposed && this.kind === 'server')
|
|
36
|
+
throw new DisposedException(`'${this.locator.id}' has been taken down, and what reached it here was started by ` +
|
|
37
|
+
'something that outlived it');
|
|
25
38
|
if (!(endpoint in this.operations))
|
|
26
39
|
throw new EndpointException(`'${endpoint}' is not provided by '${this.locator.id}'`);
|
|
27
40
|
// if the request carries no telemetry, the trace starts here
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../source/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAoB,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../source/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAoB,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AASnC,yEAAyE;AACzE,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,MAAM,CAAE,KAA4B,CAAC,IAAI,IAAI,YAAY,CAAC,CAAA;AACnE,CAAC;AAED,MAAM,OAAO,SAA2C,SAAQ,SAAS;IACvD,OAAO,CAAS;IAEb,UAAU,CAAmB;IAEtC,IAAI,GAAwB,QAAQ,CAAA;IAE9C,gCAAgC;IACvB,MAAM,GAAgC,EAAE,CAAA;IAEjD,mFAAmF;IAC1E,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;IAEjC,YAAmB,OAAgB,EAAE,UAA6B;QAChE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,MAAM,CAAC,MAAM,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AAI,CAAC;YACjC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;SAC1D,CAAC,CAAA;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAgB;QACpB,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAEnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA;YAE9E,OAAO,GAAG;gBACR,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,QAAQ,EAAE;gBACtC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,OAAO,EAAE;oBACP,SAAS,EAAE,YAAY,CAAC,QAAQ;oBAChC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;iBAC5D;aACF,CAAA;YAED,4EAA4E;YAC5E,kEAAkE;YAClE,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAA;YAE7D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAA;QACjC,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connector } from './connector.ts';
|
|
2
2
|
export declare class Composition extends Connector {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(producers: Connector[], receivers: Connector[], tenants: Connector[]);
|
|
4
4
|
protected open(): Promise<void>;
|
|
5
5
|
protected dispose(): Promise<void>;
|
|
6
6
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { console } from 'openspan';
|
|
2
2
|
import { Connector } from './connector.js';
|
|
3
3
|
export class Composition extends Connector {
|
|
4
|
-
|
|
5
|
-
constructor(expositions, producers, receivers, tenants) {
|
|
4
|
+
constructor(producers, receivers, tenants) {
|
|
6
5
|
super();
|
|
7
|
-
if (expositions.length > 0)
|
|
8
|
-
this.depends(expositions);
|
|
9
6
|
if (producers.length > 0)
|
|
10
7
|
this.depends(producers);
|
|
11
8
|
if (receivers.length > 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition.js","sourceRoot":"","sources":["../source/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,
|
|
1
|
+
{"version":3,"file":"composition.js","sourceRoot":"","sources":["../source/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,YACE,SAAsB,EACtB,SAAsB,EACtB,OAAoB;QAEpB,KAAK,EAAE,CAAA;QAEP,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACjD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACjD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;IAEkB,KAAK,CAAC,IAAI;QAC3B,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;IACtC,CAAC;IAEkB,KAAK,CAAC,OAAO;QAC9B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;IAC/C,CAAC;CACF"}
|
|
@@ -46,6 +46,23 @@ export declare class Connector {
|
|
|
46
46
|
reconnect(): Promise<void>;
|
|
47
47
|
debug(node?: Record<string, any>): Record<string, any>;
|
|
48
48
|
/** Called on connection */
|
|
49
|
+
/**
|
|
50
|
+
* Stops what this tree does of its own accord, holding every connection open.
|
|
51
|
+
*
|
|
52
|
+
* The walk is what reaches a connector; what the connector does about it is `stop`. Top down,
|
|
53
|
+
* so a source is stopped before whatever it feeds, and a failure is reported rather than
|
|
54
|
+
* raised — one connector that will not stop is no reason to leave the rest working.
|
|
55
|
+
*/
|
|
56
|
+
halt(visited?: Set<Connector>): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Starts again what `halt` stopped, bottom up, so nothing works before what it works through.
|
|
59
|
+
* Runs wherever the halt went, including where it failed.
|
|
60
|
+
*/
|
|
61
|
+
restore(visited?: Set<Connector>): Promise<void>;
|
|
62
|
+
/** What this stops doing of its own accord while the tree is halted. See `halt`. */
|
|
63
|
+
protected pause(): Promise<void> | void;
|
|
64
|
+
/** What it starts doing again. See `restore`. */
|
|
65
|
+
protected unpause(): Promise<void> | void;
|
|
49
66
|
protected open(): Promise<void> | void;
|
|
50
67
|
/** Called on disconnection */
|
|
51
68
|
protected close(): Promise<void> | void;
|
package/transpiled/connector.js
CHANGED
|
@@ -7,6 +7,8 @@ export class Connector {
|
|
|
7
7
|
#connecting;
|
|
8
8
|
#disconnecting;
|
|
9
9
|
#discarded = false;
|
|
10
|
+
/** Whether this has been told to stop what it does of its own accord, see `halt`. */
|
|
11
|
+
#halted = false;
|
|
10
12
|
id;
|
|
11
13
|
connected = false;
|
|
12
14
|
/**
|
|
@@ -47,6 +49,10 @@ export class Connector {
|
|
|
47
49
|
// See .#discard()
|
|
48
50
|
if (this.#disconnecting !== undefined)
|
|
49
51
|
next.#discard();
|
|
52
|
+
// and the same for a quiescence the walk has gone past already: one taken on after it
|
|
53
|
+
// would otherwise be the one thing in the tree still working
|
|
54
|
+
if (this.#halted)
|
|
55
|
+
void next.halt();
|
|
50
56
|
return next;
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
@@ -182,6 +188,55 @@ export class Connector {
|
|
|
182
188
|
return node;
|
|
183
189
|
}
|
|
184
190
|
/** Called on connection */
|
|
191
|
+
/**
|
|
192
|
+
* Stops what this tree does of its own accord, holding every connection open.
|
|
193
|
+
*
|
|
194
|
+
* The walk is what reaches a connector; what the connector does about it is `stop`. Top down,
|
|
195
|
+
* so a source is stopped before whatever it feeds, and a failure is reported rather than
|
|
196
|
+
* raised — one connector that will not stop is no reason to leave the rest working.
|
|
197
|
+
*/
|
|
198
|
+
async halt(visited = new Set()) {
|
|
199
|
+
// the walk is governed by where it has been, and the flag only by whether this one has
|
|
200
|
+
// already stopped: a connector that has, with a subtree that has not, is still walked through
|
|
201
|
+
if (visited.has(this))
|
|
202
|
+
return;
|
|
203
|
+
visited.add(this);
|
|
204
|
+
if (!this.#halted) {
|
|
205
|
+
this.#halted = true;
|
|
206
|
+
try {
|
|
207
|
+
await this.pause();
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
console.error('Connector failed to pause', { id: this.id, error });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const dependency of this.#dependencies)
|
|
214
|
+
await dependency.halt(visited);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Starts again what `halt` stopped, bottom up, so nothing works before what it works through.
|
|
218
|
+
* Runs wherever the halt went, including where it failed.
|
|
219
|
+
*/
|
|
220
|
+
async restore(visited = new Set()) {
|
|
221
|
+
if (visited.has(this))
|
|
222
|
+
return;
|
|
223
|
+
visited.add(this);
|
|
224
|
+
for (const dependency of this.#dependencies)
|
|
225
|
+
await dependency.restore(visited);
|
|
226
|
+
if (!this.#halted)
|
|
227
|
+
return;
|
|
228
|
+
this.#halted = false;
|
|
229
|
+
try {
|
|
230
|
+
await this.unpause();
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
console.error('Connector failed to unpause', { id: this.id, error });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** What this stops doing of its own accord while the tree is halted. See `halt`. */
|
|
237
|
+
pause() { }
|
|
238
|
+
/** What it starts doing again. See `restore`. */
|
|
239
|
+
unpause() { }
|
|
185
240
|
open() { }
|
|
186
241
|
/** Called on disconnection */
|
|
187
242
|
close() { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../source/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,qCAAqC;AACrC,MAAM,OAAO,SAAS;IACpB,aAAa,GAAgB,EAAE,CAAA;IAC/B,MAAM,GAAgB,EAAE,CAAA;IACxB,WAAW,CAA2B;IACtC,cAAc,CAA2B;IACzC,UAAU,GAAY,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../source/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,qCAAqC;AACrC,MAAM,OAAO,SAAS;IACpB,aAAa,GAAgB,EAAE,CAAA;IAC/B,MAAM,GAAgB,EAAE,CAAA;IACxB,WAAW,CAA2B;IACtC,cAAc,CAA2B;IACzC,UAAU,GAAY,KAAK,CAAA;IAE3B,qFAAqF;IACrF,OAAO,GAAY,KAAK,CAAA;IAER,EAAE,CAAQ;IACnB,SAAS,GAAY,KAAK,CAAA;IAEjC;;;;;OAKG;IACI,QAAQ,GAAY,KAAK,CAAA;IAEhC;QACE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,EAA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C,8BAA8B;IACpB,KAAK,KAA0B,CAAC;IAE1C,iEAAiE;IACvD,OAAO,KAA0B,CAAC;CAC7C;AAED,MAAM,KAAK,GAAG,IAAI,CAAA;AAClB,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,GAAG,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Definition, Entity } from './request.ts';
|
|
2
|
+
/** What a caller is given in order to call a component: what a map states of it. */
|
|
3
|
+
export interface Contract {
|
|
4
|
+
/** the version of the component this describes */
|
|
5
|
+
version?: string;
|
|
6
|
+
entity?: Entity;
|
|
7
|
+
operations?: Record<string, Operation>;
|
|
8
|
+
events?: Record<string, Event>;
|
|
9
|
+
}
|
|
10
|
+
export interface Operation extends Definition {
|
|
11
|
+
bindings?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface Event {
|
|
14
|
+
binding: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What a caller is given of a component, of what its normalised manifest holds.
|
|
18
|
+
*
|
|
19
|
+
* What a component states about serving a call rather than about making one is its own: an
|
|
20
|
+
* operation's concurrency, the bridge that runs it and what it forwards to, and the entity's
|
|
21
|
+
* storage, its blank and its migrations. An event's `path` is a path in the process that
|
|
22
|
+
* normalised the manifest, and names nothing in any other.
|
|
23
|
+
*/
|
|
24
|
+
export declare function component(manifest: Contract): Contract;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a caller is given of a component, of what its normalised manifest holds.
|
|
3
|
+
*
|
|
4
|
+
* What a component states about serving a call rather than about making one is its own: an
|
|
5
|
+
* operation's concurrency, the bridge that runs it and what it forwards to, and the entity's
|
|
6
|
+
* storage, its blank and its migrations. An event's `path` is a path in the process that
|
|
7
|
+
* normalised the manifest, and names nothing in any other.
|
|
8
|
+
*/
|
|
9
|
+
export function component(manifest) {
|
|
10
|
+
const contract = { version: manifest.version };
|
|
11
|
+
if (manifest.entity !== undefined)
|
|
12
|
+
contract.entity = {
|
|
13
|
+
properties: manifest.entity.properties,
|
|
14
|
+
required: manifest.entity.required
|
|
15
|
+
};
|
|
16
|
+
if (manifest.operations !== undefined) {
|
|
17
|
+
contract.operations = {};
|
|
18
|
+
for (const [endpoint, definition] of Object.entries(manifest.operations))
|
|
19
|
+
contract.operations[endpoint] = operation(definition);
|
|
20
|
+
}
|
|
21
|
+
if (manifest.events !== undefined) {
|
|
22
|
+
contract.events = {};
|
|
23
|
+
for (const [event, definition] of Object.entries(manifest.events))
|
|
24
|
+
contract.events[event] = { binding: definition.binding };
|
|
25
|
+
}
|
|
26
|
+
return contract;
|
|
27
|
+
}
|
|
28
|
+
function operation(definition) {
|
|
29
|
+
const operation = {};
|
|
30
|
+
for (const key of KEYS)
|
|
31
|
+
if (definition[key] !== undefined)
|
|
32
|
+
operation[key] = definition[key];
|
|
33
|
+
return operation;
|
|
34
|
+
}
|
|
35
|
+
/** What a call to an operation is addressed by, carries, answers and refuses with. */
|
|
36
|
+
const KEYS = [
|
|
37
|
+
'type',
|
|
38
|
+
'scope',
|
|
39
|
+
'query',
|
|
40
|
+
'once',
|
|
41
|
+
'stateful',
|
|
42
|
+
'bindings',
|
|
43
|
+
'description',
|
|
44
|
+
'input',
|
|
45
|
+
'output',
|
|
46
|
+
'errors'
|
|
47
|
+
];
|
|
48
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../source/contract/component.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,QAAkB;IAC1C,MAAM,QAAQ,GAAa,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAA;IAExD,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC/B,QAAQ,CAAC,MAAM,GAAG;YAChB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU;YACtC,QAAQ,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AO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The messages this process has taken and not yet finished with.
|
|
3
|
+
*
|
|
4
|
+
* A binding counts one in for as long as it holds a delivery, and that is exactly what its own
|
|
5
|
+
* teardown waits for: a connection cannot close while a message it dispatched is still being
|
|
6
|
+
* handled, and a handler waiting on a call of its own holds it there. So this answers, for the
|
|
7
|
+
* process as a whole, whether a teardown has anything left to wait on.
|
|
8
|
+
*
|
|
9
|
+
* It is not `toa.call.inflight`, which counts the other side — callers waiting. That number is
|
|
10
|
+
* non-zero for a call a gateway made, which blocks no teardown, and zero for a handler held open
|
|
11
|
+
* by a database commit, which blocks one.
|
|
12
|
+
*
|
|
13
|
+
* Ambient, like the instance name and the invocation chain, and for the same reason: a process
|
|
14
|
+
* may carry two copies of this module, and a count kept in one of them answers for half a
|
|
15
|
+
* process.
|
|
16
|
+
*/
|
|
17
|
+
/** One more delivery is being handled. */
|
|
18
|
+
export declare function taken(): void;
|
|
19
|
+
/** One fewer: the handler has returned, however it returned. */
|
|
20
|
+
export declare function done(): void;
|
|
21
|
+
/** How many this process is handling now. */
|
|
22
|
+
export declare function inflight(): number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The messages this process has taken and not yet finished with.
|
|
3
|
+
*
|
|
4
|
+
* A binding counts one in for as long as it holds a delivery, and that is exactly what its own
|
|
5
|
+
* teardown waits for: a connection cannot close while a message it dispatched is still being
|
|
6
|
+
* handled, and a handler waiting on a call of its own holds it there. So this answers, for the
|
|
7
|
+
* process as a whole, whether a teardown has anything left to wait on.
|
|
8
|
+
*
|
|
9
|
+
* It is not `toa.call.inflight`, which counts the other side — callers waiting. That number is
|
|
10
|
+
* non-zero for a call a gateway made, which blocks no teardown, and zero for a handler held open
|
|
11
|
+
* by a database commit, which blocks one.
|
|
12
|
+
*
|
|
13
|
+
* Ambient, like the instance name and the invocation chain, and for the same reason: a process
|
|
14
|
+
* may carry two copies of this module, and a count kept in one of them answers for half a
|
|
15
|
+
* process.
|
|
16
|
+
*/
|
|
17
|
+
const KEY = Symbol.for('toa.core.deliveries');
|
|
18
|
+
const store = (globalThis[KEY] ??= { count: 0 });
|
|
19
|
+
/** One more delivery is being handled. */
|
|
20
|
+
export function taken() {
|
|
21
|
+
store.count++;
|
|
22
|
+
}
|
|
23
|
+
/** One fewer: the handler has returned, however it returned. */
|
|
24
|
+
export function done() {
|
|
25
|
+
store.count--;
|
|
26
|
+
}
|
|
27
|
+
/** How many this process is handling now. */
|
|
28
|
+
export function inflight() {
|
|
29
|
+
return store.count;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=deliveries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveries.js","sourceRoot":"","sources":["../source/deliveries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAI7C,MAAM,KAAK,GAAG,CAAE,UAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;AAE3D,0CAA0C;AAC1C,MAAM,UAAU,KAAK;IACnB,KAAK,CAAC,KAAK,EAAE,CAAA;AACf,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,IAAI;IAClB,KAAK,CAAC,KAAK,EAAE,CAAA;AACf,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,QAAQ;IACtB,OAAO,KAAK,CAAC,KAAK,CAAA;AACpB,CAAC"}
|
|
@@ -24,12 +24,18 @@ export declare const codes: {
|
|
|
24
24
|
Addressee: number;
|
|
25
25
|
/** the caller stopped waiting, and what it called may still run */
|
|
26
26
|
Abandoned: number;
|
|
27
|
+
/** the tree the call was made through has been taken down, and is not coming back */
|
|
28
|
+
Disposed: number;
|
|
29
|
+
/** a call to an operation that may change state, made under a request that may only read */
|
|
30
|
+
Safety: number;
|
|
27
31
|
/** a chain that came back to where it had been, or went further than a chain goes */
|
|
28
32
|
Loop: number;
|
|
29
33
|
/** a component asked for something its manifest does not declare */
|
|
30
34
|
Misuse: number;
|
|
31
|
-
/** a
|
|
32
|
-
|
|
35
|
+
/** a run command pauses what nothing takes again: `pause` with no `resume` */
|
|
36
|
+
Irresumable: number;
|
|
37
|
+
/** a call to a component nothing this process was given states */
|
|
38
|
+
Unstated: number;
|
|
33
39
|
};
|
|
34
40
|
export declare class Exception {
|
|
35
41
|
readonly code: number;
|
|
@@ -83,8 +89,11 @@ export declare const TransmissionException: Derived;
|
|
|
83
89
|
export declare const EndpointException: Derived;
|
|
84
90
|
export declare const AddresseeException: Derived;
|
|
85
91
|
export declare const AbandonedException: Derived;
|
|
86
|
-
export declare const
|
|
92
|
+
export declare const DisposedException: Derived;
|
|
87
93
|
export declare const SafetyException: Derived;
|
|
94
|
+
export declare const MisuseException: Derived;
|
|
95
|
+
export declare const IrresumableException: Derived;
|
|
96
|
+
export declare const UnstatedException: Derived;
|
|
88
97
|
export declare const names: Record<string, string>;
|
|
89
98
|
/**
|
|
90
99
|
* Takes `unknown` because a caller has caught something rather than been handed an `Exception`.
|
package/transpiled/exceptions.js
CHANGED
|
@@ -24,12 +24,18 @@ export const codes = {
|
|
|
24
24
|
Addressee: 403,
|
|
25
25
|
/** the caller stopped waiting, and what it called may still run */
|
|
26
26
|
Abandoned: 404,
|
|
27
|
+
/** the tree the call was made through has been taken down, and is not coming back */
|
|
28
|
+
Disposed: 405,
|
|
29
|
+
/** a call to an operation that may change state, made under a request that may only read */
|
|
30
|
+
Safety: 406,
|
|
27
31
|
/** a chain that came back to where it had been, or went further than a chain goes */
|
|
28
32
|
Loop: 500,
|
|
29
33
|
/** a component asked for something its manifest does not declare */
|
|
30
34
|
Misuse: 600,
|
|
31
|
-
/** a
|
|
32
|
-
|
|
35
|
+
/** a run command pauses what nothing takes again: `pause` with no `resume` */
|
|
36
|
+
Irresumable: 601,
|
|
37
|
+
/** a call to a component nothing this process was given states */
|
|
38
|
+
Unstated: 602
|
|
33
39
|
};
|
|
34
40
|
export class Exception {
|
|
35
41
|
code;
|
|
@@ -123,8 +129,11 @@ export const TransmissionException = derive('Transmission');
|
|
|
123
129
|
export const EndpointException = derive('Endpoint');
|
|
124
130
|
export const AddresseeException = derive('Addressee');
|
|
125
131
|
export const AbandonedException = derive('Abandoned');
|
|
126
|
-
export const
|
|
132
|
+
export const DisposedException = derive('Disposed');
|
|
127
133
|
export const SafetyException = derive('Safety');
|
|
134
|
+
export const MisuseException = derive('Misuse');
|
|
135
|
+
export const IrresumableException = derive('Irresumable');
|
|
136
|
+
export const UnstatedException = derive('Unstated');
|
|
128
137
|
export const names = swap(codes);
|
|
129
138
|
// #endregion
|
|
130
139
|
/**
|
|
@@ -168,12 +177,18 @@ const OUTCOME = {
|
|
|
168
177
|
Addressee: 'transient',
|
|
169
178
|
// what the caller gave up on may have run, and may run yet
|
|
170
179
|
Abandoned: 'transient',
|
|
180
|
+
// the tree is gone and a resume builds another, so the same context never works again
|
|
181
|
+
Disposed: 'permanent',
|
|
182
|
+
// a transition does not become an observation, and the request goes on saying it only reads
|
|
183
|
+
Safety: 'permanent',
|
|
171
184
|
// the chain is deterministic, so another attempt walks it again: a retry is another cycle
|
|
172
185
|
Loop: 'permanent',
|
|
173
186
|
// what a component did not declare, it does not declare on the next attempt either
|
|
174
187
|
Misuse: 'permanent',
|
|
175
|
-
//
|
|
176
|
-
|
|
188
|
+
// the component is refused at start, so nothing reaches it to be attempted twice
|
|
189
|
+
Irresumable: 'permanent',
|
|
190
|
+
// a remote is built once and held, so what this process was not given, it is not given later
|
|
191
|
+
Unstated: 'permanent'
|
|
177
192
|
};
|
|
178
193
|
const PERMANENT = new Set(Object.entries(OUTCOME)
|
|
179
194
|
.filter(([, outcome]) => outcome === 'permanent')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../source/exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAGtC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,CAAC;IAET,QAAQ,EAAE,GAAG;IACb,aAAa,EAAE,GAAG;IAClB,eAAe,EAAE,GAAG;IACpB,eAAe,EAAE,GAAG;IACpB,gBAAgB,EAAE,GAAG;IACrB,cAAc,EAAE,GAAG;IACnB,WAAW,EAAE,GAAG;IAChB,WAAW,EAAE,GAAG;IAEhB,KAAK,EAAE,GAAG;IACV,aAAa,EAAE,GAAG;IAClB,iBAAiB,EAAE,GAAG;IACtB,gBAAgB,EAAE,GAAG;IACrB,mBAAmB,EAAE,GAAG;IACxB,SAAS,EAAE,GAAG;IACd,8DAA8D;IAC9D,aAAa,EAAE,GAAG;IAElB,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,GAAG;IACjB,QAAQ,EAAE,GAAG;IACb,oDAAoD;IACpD,SAAS,EAAE,GAAG;IACd,mEAAmE;IACnE,SAAS,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../source/exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAGtC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,CAAC;IAET,QAAQ,EAAE,GAAG;IACb,aAAa,EAAE,GAAG;IAClB,eAAe,EAAE,GAAG;IACpB,eAAe,EAAE,GAAG;IACpB,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D,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Connector } from './connector.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A part of a tree that a halt takes down and builds again.
|
|
4
|
+
*
|
|
5
|
+
* What it holds it *owns*, rather than depends on: a connector with a live dependant refuses to
|
|
6
|
+
* disconnect, and the one way past that refusal skips `close()` with it. A subtree nobody links
|
|
7
|
+
* has neither problem, so the teardown here is the one a shutdown performs.
|
|
8
|
+
*
|
|
9
|
+
* And the subtree is discarded rather than kept, because what comes back is built anew: a sealed
|
|
10
|
+
* communication, a receiver that has stopped announcing, an algorithm that has been unmounted —
|
|
11
|
+
* none of them are asked to work a second time. Nothing outlives a halt but what is above it.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Gate extends Connector {
|
|
14
|
+
private readonly build;
|
|
15
|
+
private live;
|
|
16
|
+
/** While halted, when what this holds comes back; `0` where it is not halted. */
|
|
17
|
+
private resumesAt;
|
|
18
|
+
constructor(build: () => Promise<Connector>);
|
|
19
|
+
/** Whether what this holds is up. */
|
|
20
|
+
holding(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Seconds until what this holds is back, and `0` where it is up or is not coming back.
|
|
23
|
+
*
|
|
24
|
+
* What sits above a gate answers for it while it is down — the gateway keeps its port and
|
|
25
|
+
* replies `503` rather than closing it — and this is what such a reply says to come back
|
|
26
|
+
* after.
|
|
27
|
+
*/
|
|
28
|
+
remaining(): number;
|
|
29
|
+
/**
|
|
30
|
+
* @param seconds how long it stays down, where it is coming back
|
|
31
|
+
*/
|
|
32
|
+
down(seconds?: number): Promise<void>;
|
|
33
|
+
up(): Promise<void>;
|
|
34
|
+
/** What a gate holds is not a dependency, so the walks that stop a tree are led into it. */
|
|
35
|
+
halt(visited?: Set<Connector>): Promise<void>;
|
|
36
|
+
restore(visited?: Set<Connector>): Promise<void>;
|
|
37
|
+
debug(node?: Record<string, any>): Record<string, any>;
|
|
38
|
+
protected open(): Promise<void>;
|
|
39
|
+
protected close(): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Connector } from './connector.js';
|
|
2
|
+
/**
|
|
3
|
+
* A part of a tree that a halt takes down and builds again.
|
|
4
|
+
*
|
|
5
|
+
* What it holds it *owns*, rather than depends on: a connector with a live dependant refuses to
|
|
6
|
+
* disconnect, and the one way past that refusal skips `close()` with it. A subtree nobody links
|
|
7
|
+
* has neither problem, so the teardown here is the one a shutdown performs.
|
|
8
|
+
*
|
|
9
|
+
* And the subtree is discarded rather than kept, because what comes back is built anew: a sealed
|
|
10
|
+
* communication, a receiver that has stopped announcing, an algorithm that has been unmounted —
|
|
11
|
+
* none of them are asked to work a second time. Nothing outlives a halt but what is above it.
|
|
12
|
+
*/
|
|
13
|
+
export class Gate extends Connector {
|
|
14
|
+
build;
|
|
15
|
+
live = null;
|
|
16
|
+
/** While halted, when what this holds comes back; `0` where it is not halted. */
|
|
17
|
+
resumesAt = 0;
|
|
18
|
+
constructor(build) {
|
|
19
|
+
super();
|
|
20
|
+
this.build = build;
|
|
21
|
+
}
|
|
22
|
+
/** Whether what this holds is up. */
|
|
23
|
+
holding() {
|
|
24
|
+
return this.live !== null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Seconds until what this holds is back, and `0` where it is up or is not coming back.
|
|
28
|
+
*
|
|
29
|
+
* What sits above a gate answers for it while it is down — the gateway keeps its port and
|
|
30
|
+
* replies `503` rather than closing it — and this is what such a reply says to come back
|
|
31
|
+
* after.
|
|
32
|
+
*/
|
|
33
|
+
remaining() {
|
|
34
|
+
if (this.resumesAt === 0)
|
|
35
|
+
return 0;
|
|
36
|
+
return Math.max(0, Math.ceil((this.resumesAt - Date.now()) / 1000));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @param seconds how long it stays down, where it is coming back
|
|
40
|
+
*/
|
|
41
|
+
async down(seconds = 0) {
|
|
42
|
+
const live = this.live;
|
|
43
|
+
if (live === null)
|
|
44
|
+
return;
|
|
45
|
+
this.live = null;
|
|
46
|
+
this.resumesAt = seconds === 0 ? 0 : Date.now() + seconds * 1000;
|
|
47
|
+
await live.disconnect();
|
|
48
|
+
}
|
|
49
|
+
async up() {
|
|
50
|
+
this.resumesAt = 0;
|
|
51
|
+
if (this.live !== null)
|
|
52
|
+
return;
|
|
53
|
+
const live = await this.build();
|
|
54
|
+
// held only once it is up: a build that throws leaves nothing to take down
|
|
55
|
+
await live.connect();
|
|
56
|
+
this.live = live;
|
|
57
|
+
}
|
|
58
|
+
/** What a gate holds is not a dependency, so the walks that stop a tree are led into it. */
|
|
59
|
+
async halt(visited = new Set()) {
|
|
60
|
+
if (visited.has(this))
|
|
61
|
+
return;
|
|
62
|
+
await super.halt(visited);
|
|
63
|
+
await this.live?.halt(visited);
|
|
64
|
+
}
|
|
65
|
+
async restore(visited = new Set()) {
|
|
66
|
+
if (visited.has(this))
|
|
67
|
+
return;
|
|
68
|
+
await this.live?.restore(visited);
|
|
69
|
+
await super.restore(visited);
|
|
70
|
+
}
|
|
71
|
+
debug(node = {}) {
|
|
72
|
+
super.debug(node);
|
|
73
|
+
// what a gate holds is not a dependency, so the walk does not reach it on its own
|
|
74
|
+
this.live?.debug(node[this.id]);
|
|
75
|
+
return node;
|
|
76
|
+
}
|
|
77
|
+
async open() {
|
|
78
|
+
await this.up();
|
|
79
|
+
}
|
|
80
|
+
async close() {
|
|
81
|
+
await this.down();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../source/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAK,SAAQ,SAAS;IAChB,KAAK,CAA0B;IACxC,IAAI,GAAqB,IAAI,CAAA;IAErC,iFAAiF;IACzE,SAAS,GAA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;QAC5D,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAM;QAE7B,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzB,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAEe,KAAK,CAAC,OAAO,CAAC,OAAO,GAAmB,IAAI,GAAG,EAAE;QAC/D,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAM;QAE7B,MAAM,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;QACjC,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9B,CAAC;IAEe,KAAK,CAAC,IAAI,GAAwB,EAAE;QAClD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEjB,kFAAkF;QAClF,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QAE/B,OAAO,IAAI,CAAA;IACb,CAAC;IAEkB,KAAK,CAAC,IAAI;QAC3B,MAAM,IAAI,CAAC,EAAE,EAAE,CAAA;IACjB,CAAC;IAEkB,KAAK,CAAC,KAAK;QAC5B,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this process is halting.
|
|
3
|
+
*
|
|
4
|
+
* A halt is the one teardown that is not a shutdown: the process stays, and what it held is
|
|
5
|
+
* built again. Two things read this and act differently because of it — a connection gives up
|
|
6
|
+
* the replies it is waiting for rather than holding the teardown open for a peer that is
|
|
7
|
+
* halting too, and a rejection from a tree that has been taken down is reported rather than
|
|
8
|
+
* fatal, because the process is in exactly the state the runtime put it in.
|
|
9
|
+
*
|
|
10
|
+
* Ambient, like the instance name and the invocation chain, and for the same reason: a process
|
|
11
|
+
* may carry two copies of this module, and an answer from one of them answers for half a
|
|
12
|
+
* process.
|
|
13
|
+
*/
|
|
14
|
+
export declare function begin(): void;
|
|
15
|
+
export declare function end(): void;
|
|
16
|
+
export declare function underway(): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this process is halting.
|
|
3
|
+
*
|
|
4
|
+
* A halt is the one teardown that is not a shutdown: the process stays, and what it held is
|
|
5
|
+
* built again. Two things read this and act differently because of it — a connection gives up
|
|
6
|
+
* the replies it is waiting for rather than holding the teardown open for a peer that is
|
|
7
|
+
* halting too, and a rejection from a tree that has been taken down is reported rather than
|
|
8
|
+
* fatal, because the process is in exactly the state the runtime put it in.
|
|
9
|
+
*
|
|
10
|
+
* Ambient, like the instance name and the invocation chain, and for the same reason: a process
|
|
11
|
+
* may carry two copies of this module, and an answer from one of them answers for half a
|
|
12
|
+
* process.
|
|
13
|
+
*/
|
|
14
|
+
const KEY = Symbol.for('toa.core.halting');
|
|
15
|
+
const store = (globalThis[KEY] ??= { underway: false });
|
|
16
|
+
export function begin() {
|
|
17
|
+
store.underway = true;
|
|
18
|
+
}
|
|
19
|
+
export function end() {
|
|
20
|
+
store.underway = false;
|
|
21
|
+
}
|
|
22
|
+
export function underway() {
|
|
23
|
+
return store.underway;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=halting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halting.js","sourceRoot":"","sources":["../source/halting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AAI1C,MAAM,KAAK,GAAG,CAAE,UAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;AAElE,MAAM,UAAU,KAAK;IACnB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,KAAK,CAAC,QAAQ,CAAA;AACvB,CAAC"}
|
package/transpiled/index.d.ts
CHANGED
|
@@ -5,12 +5,11 @@ export { Component } from './component.ts';
|
|
|
5
5
|
export { Composition } from './composition.ts';
|
|
6
6
|
export { Connector } from './connector.ts';
|
|
7
7
|
export { Context } from './context.ts';
|
|
8
|
-
export { Discovery } from './discovery.ts';
|
|
9
8
|
export { Encoded } from './encoded.ts';
|
|
10
9
|
export { Effect } from './effect.ts';
|
|
11
10
|
export { Emission } from './emission.ts';
|
|
12
11
|
export { Event } from './event.ts';
|
|
13
|
-
export {
|
|
12
|
+
export { Gate } from './gate.ts';
|
|
14
13
|
export { Locator } from './locator.ts';
|
|
15
14
|
export { Observation } from './observation.ts';
|
|
16
15
|
export { Outbox } from './outbox.ts';
|
|
@@ -26,7 +25,9 @@ export { Unmanaged } from './unmanaged.ts';
|
|
|
26
25
|
export { Guard } from './guard.ts';
|
|
27
26
|
export { instance } from './instance.ts';
|
|
28
27
|
export { safe } from './safety.ts';
|
|
28
|
+
export * as deliveries from './deliveries.ts';
|
|
29
29
|
export * as entities from './entities/index.ts';
|
|
30
|
+
export * as halting from './halting.ts';
|
|
30
31
|
export * as exceptions from './exceptions.ts';
|
|
31
32
|
export * as trail from './trail.ts';
|
|
32
33
|
export * as contract from './contract/index.ts';
|
|
@@ -36,4 +37,5 @@ export type { Explicable } from './remote.ts';
|
|
|
36
37
|
export type { Scoped, Store } from './operation.ts';
|
|
37
38
|
export type { Source as ReflectionSource } from './reflection.ts';
|
|
38
39
|
export type { Explanation } from './contract/request.ts';
|
|
40
|
+
export type { Contract } from './contract/component.ts';
|
|
39
41
|
export type { JSONSchema } from './contract/schemas.ts';
|
package/transpiled/index.js
CHANGED
|
@@ -5,12 +5,11 @@ export { Component } from './component.js';
|
|
|
5
5
|
export { Composition } from './composition.js';
|
|
6
6
|
export { Connector } from './connector.js';
|
|
7
7
|
export { Context } from './context.js';
|
|
8
|
-
export { Discovery } from './discovery.js';
|
|
9
8
|
export { Encoded } from './encoded.js';
|
|
10
9
|
export { Effect } from './effect.js';
|
|
11
10
|
export { Emission } from './emission.js';
|
|
12
11
|
export { Event } from './event.js';
|
|
13
|
-
export {
|
|
12
|
+
export { Gate } from './gate.js';
|
|
14
13
|
export { Locator } from './locator.js';
|
|
15
14
|
export { Observation } from './observation.js';
|
|
16
15
|
export { Outbox } from './outbox.js';
|
|
@@ -26,7 +25,9 @@ export { Unmanaged } from './unmanaged.js';
|
|
|
26
25
|
export { Guard } from './guard.js';
|
|
27
26
|
export { instance } from './instance.js';
|
|
28
27
|
export { safe } from './safety.js';
|
|
28
|
+
export * as deliveries from './deliveries.js';
|
|
29
29
|
export * as entities from './entities/index.js';
|
|
30
|
+
export * as halting from './halting.js';
|
|
30
31
|
export * as exceptions from './exceptions.js';
|
|
31
32
|
export * as trail from './trail.js';
|
|
32
33
|
export * as contract from './contract/index.js';
|
package/transpiled/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,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E,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA"}
|
|
@@ -46,7 +46,9 @@ export interface Atom extends Connector {
|
|
|
46
46
|
*
|
|
47
47
|
* Rejects where there is nothing to arbitrate through.
|
|
48
48
|
*/
|
|
49
|
-
lock<T>(keys: string | string[], routine: (signal: AbortSignal
|
|
49
|
+
lock<T>(keys: string | string[], routine: (signal: AbortSignal & {
|
|
50
|
+
error: Error;
|
|
51
|
+
}, context: unknown) => Promise<T>): Promise<T>;
|
|
50
52
|
}
|
|
51
53
|
export interface Factory {
|
|
52
54
|
/** @param group what the replicas deciding together have in common */
|
|
@@ -29,6 +29,8 @@ export interface RunCommands {
|
|
|
29
29
|
settle?: Connector;
|
|
30
30
|
ready?: Connector;
|
|
31
31
|
dispose?: Connector;
|
|
32
|
+
/** what the component pauses while the process is halted, and takes again after */
|
|
33
|
+
quiescence?: Connector;
|
|
32
34
|
}
|
|
33
35
|
export interface Factory {
|
|
34
36
|
algorithm(path: string, endpoint: string, context: Context): Algorithm | Promise<Algorithm>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Connector } from '../connector.ts';
|
|
2
|
+
import type { Gate } from '../gate.ts';
|
|
2
3
|
import type { Locator } from '../locator.ts';
|
|
3
4
|
import type { Component } from '../component.ts';
|
|
5
|
+
import type { Contract } from '../contract/component.ts';
|
|
4
6
|
import type { Remote } from '../remote.ts';
|
|
5
7
|
import type { Receiver } from './receiver.ts';
|
|
6
8
|
import type { Context } from '../context.ts';
|
|
@@ -15,7 +17,11 @@ import type { Destination } from './outbox.ts';
|
|
|
15
17
|
*/
|
|
16
18
|
export interface Host {
|
|
17
19
|
/** a component of the context, by locator */
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @param contract what the component provides, where the caller has it; absent, what the
|
|
22
|
+
* process's map states.
|
|
23
|
+
*/
|
|
24
|
+
remote(locator: Locator, source?: Source, contract?: Contract): Promise<Remote>;
|
|
19
25
|
/** a channel of the messaging binding */
|
|
20
26
|
broadcast<L extends string = string>(channel: string, group?: string): Promise<Broadcast<L>>;
|
|
21
27
|
/** components to run inside the extension's own process */
|
|
@@ -28,6 +34,21 @@ export interface Host {
|
|
|
28
34
|
outbound(binding: string, channel: string, uris: string[]): Promise<Outbound>;
|
|
29
35
|
/** what arrives on a channel under one label */
|
|
30
36
|
inbound(binding: string, channel: string, uris: string[], label: string, sink: Inbound): Promise<Connector>;
|
|
37
|
+
/**
|
|
38
|
+
* A part of this tree a halt takes down and builds again. What is not behind one of these
|
|
39
|
+
* outlives a halt: the readiness probe does, and so does whatever answers on a port the
|
|
40
|
+
* process was already listening on.
|
|
41
|
+
*/
|
|
42
|
+
gate(build: () => Promise<Connector>): Gate;
|
|
43
|
+
/**
|
|
44
|
+
* Stops what this process does of its own accord — its gateway, its clocks, its run
|
|
45
|
+
* commands — and holds open everything it has. Nothing closes, so this is reversible.
|
|
46
|
+
*/
|
|
47
|
+
quiesce(): Promise<void>;
|
|
48
|
+
/** Undoes a quiesce: the process works again, having been rebuilt by nothing. */
|
|
49
|
+
cancel(): Promise<void>;
|
|
50
|
+
/** Stops this process for `seconds`, then builds it again. */
|
|
51
|
+
stop(seconds: number): void;
|
|
31
52
|
}
|
|
32
53
|
/**
|
|
33
54
|
* `Manifest` is a type parameter rather than an import: `@toa.io/norm` depends on core, so
|
|
@@ -65,6 +86,9 @@ export interface Factory<Manifest = unknown> {
|
|
|
65
86
|
* It connects before what the process was built with and goes after it, which is what makes it
|
|
66
87
|
* the place for something that answers for the process rather than for anything in it — the
|
|
67
88
|
* readiness probe is the one this was written for.
|
|
89
|
+
*
|
|
90
|
+
* It outlives a halt. One that must not says so by being a `Host.gate`, which is a connector
|
|
91
|
+
* like any other: the gate stays, what it holds does not.
|
|
68
92
|
*/
|
|
69
93
|
export interface Resident extends Connector {
|
|
70
94
|
/** Everything the process was built with has connected. */
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Connector } from './connector.ts';
|
|
2
|
-
import type { Locator } from './locator.ts';
|
|
3
|
-
interface Lookup extends Connector {
|
|
4
|
-
invoke: () => Promise<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare class Discovery extends Connector {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(lookup: (locator: Locator) => Promise<Lookup>);
|
|
9
|
-
protected open(): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* A lookup is unbounded, so one in flight when this goes away never settles and would go on
|
|
12
|
-
* saying it is waiting for the life of the process. Which nothing noticed while a
|
|
13
|
-
* disconnected discovery meant a process on its way out — a halt takes one down and builds
|
|
14
|
-
* another, and every cycle would leave a voice behind.
|
|
15
|
-
*/
|
|
16
|
-
protected close(): Promise<void>;
|
|
17
|
-
lookup(locator: Locator): Promise<any>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
package/transpiled/discovery.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { console } from 'openspan';
|
|
2
|
-
import { Connector } from './connector.js';
|
|
3
|
-
export class Discovery extends Connector {
|
|
4
|
-
#lookup;
|
|
5
|
-
#lookups = {};
|
|
6
|
-
/** What is still saying it is waiting, so that a discovery going away can stop it. */
|
|
7
|
-
#waiting = new Set();
|
|
8
|
-
constructor(lookup) {
|
|
9
|
-
super();
|
|
10
|
-
this.#lookup = lookup;
|
|
11
|
-
}
|
|
12
|
-
async open() {
|
|
13
|
-
this.#lookups = {};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A lookup is unbounded, so one in flight when this goes away never settles and would go on
|
|
17
|
-
* saying it is waiting for the life of the process. Which nothing noticed while a
|
|
18
|
-
* disconnected discovery meant a process on its way out — a halt takes one down and builds
|
|
19
|
-
* another, and every cycle would leave a voice behind.
|
|
20
|
-
*/
|
|
21
|
-
async close() {
|
|
22
|
-
for (const warning of this.#waiting)
|
|
23
|
-
clearInterval(warning);
|
|
24
|
-
this.#waiting.clear();
|
|
25
|
-
}
|
|
26
|
-
async lookup(locator) {
|
|
27
|
-
const id = locator.id;
|
|
28
|
-
if (this.#lookups[id] === undefined) {
|
|
29
|
-
const lookup = await this.#lookup(locator);
|
|
30
|
-
this.#lookups[id] = Promise.resolve(lookup);
|
|
31
|
-
this.depends(lookup);
|
|
32
|
-
}
|
|
33
|
-
const since = Date.now();
|
|
34
|
-
// the wait is unbounded by design, as a dependency may still be starting,
|
|
35
|
-
// so repeating is the only way a component stuck on one stays visible
|
|
36
|
-
const warning = setInterval(() => {
|
|
37
|
-
const waiting = Math.round((Date.now() - since) / 1000);
|
|
38
|
-
console.warn('Waiting for lookup response', { component: id, waiting });
|
|
39
|
-
}, INTERVAL);
|
|
40
|
-
warning.unref();
|
|
41
|
-
this.#waiting.add(warning);
|
|
42
|
-
try {
|
|
43
|
-
return await (await this.#lookups[id]).invoke();
|
|
44
|
-
}
|
|
45
|
-
finally {
|
|
46
|
-
clearInterval(warning);
|
|
47
|
-
this.#waiting.delete(warning);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const INTERVAL = 5000;
|
|
52
|
-
//# sourceMappingURL=discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../source/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO1C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAC7B,OAAO,CAAuC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AC,CAAA;QAEZ,OAAO,CAAC,KAAK,EAAE,CAAA;QACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAE1B,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QACjD,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,OAAO,CAAC,CAAA;YACtB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Connector } from './connector.ts';
|
|
2
|
-
import type { Locator } from './locator.ts';
|
|
3
|
-
interface Manifest {
|
|
4
|
-
namespace: string;
|
|
5
|
-
name: string;
|
|
6
|
-
entity?: object;
|
|
7
|
-
operations?: object;
|
|
8
|
-
events?: object;
|
|
9
|
-
}
|
|
10
|
-
export declare class Exposition extends Connector {
|
|
11
|
-
#private;
|
|
12
|
-
readonly locator: Locator;
|
|
13
|
-
constructor(locator: Locator, manifest: Manifest);
|
|
14
|
-
invoke(): Promise<{
|
|
15
|
-
output: Partial<Manifest>;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
package/transpiled/exposition.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Connector } from './connector.js';
|
|
2
|
-
export class Exposition extends Connector {
|
|
3
|
-
locator;
|
|
4
|
-
#exposition;
|
|
5
|
-
constructor(locator, manifest) {
|
|
6
|
-
super();
|
|
7
|
-
this.locator = locator;
|
|
8
|
-
this.#exposition = expose(manifest);
|
|
9
|
-
}
|
|
10
|
-
async invoke() {
|
|
11
|
-
return { output: this.#exposition };
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function expose(manifest) {
|
|
15
|
-
const { namespace, name, entity, operations, events } = manifest;
|
|
16
|
-
return { namespace, name, entity, operations, events };
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=exposition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exposition.js","sourceRoot":"","sources":["../source/exposition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAW1C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvB,OAAO,CAAS;IAEvB,WAAW,CAAmB;IAEvC,YAAmB,OAAgB,EAAE,QAAkB;QACrD,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;CACF;AAED,SAAS,MAAM,CAAC,QAAkB;IAChC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;IAEhE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;AACxD,CAAC"}
|