@toa.io/core 1.0.0-alpha.305 → 1.0.0-alpha.306
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/connector.d.ts +17 -0
- package/transpiled/connector.js +55 -0
- package/transpiled/connector.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/discovery.d.ts +6 -2
- package/transpiled/discovery.js +16 -6
- package/transpiled/discovery.js.map +1 -1
- package/transpiled/exceptions.d.ts +9 -3
- package/transpiled/exceptions.js +15 -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 +3 -0
- package/transpiled/index.js +3 -0
- 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 +24 -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.306",
|
|
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": "0693d180a8053a7d07dca879dac2a3c4784d6d45"
|
|
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,SAA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AG,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"}
|
|
@@ -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;IAC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AC,IAAI,CAAC;YAAE,OAAM;QAE7B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEjB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,aAAa;YAAE,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAE9E,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QAEpB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;IAED,oFAAoF;IAC1E,KAAK,KAA0B,CAAC;IAE1C,iDAAiD;IACvC,OAAO,KAA0B,CAAC;IAElC,IAAI,KAA0B,CAAC;IAEzC,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,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"}
|
|
@@ -5,7 +5,7 @@ interface Lookup extends Connector {
|
|
|
5
5
|
}
|
|
6
6
|
export declare class Discovery extends Connector {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(lookup: (locator: Locator) => Promise<Lookup>);
|
|
8
|
+
constructor(lookup: (locator: Locator, version?: string) => Promise<Lookup>);
|
|
9
9
|
protected open(): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* A lookup is unbounded, so one in flight when this goes away never settles and would go on
|
|
@@ -14,6 +14,10 @@ export declare class Discovery extends Connector {
|
|
|
14
14
|
* another, and every cycle would leave a voice behind.
|
|
15
15
|
*/
|
|
16
16
|
protected close(): Promise<void>;
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @param locator the component asked
|
|
19
|
+
* @param version which of its versions answers; absent, whichever of them takes the message
|
|
20
|
+
*/
|
|
21
|
+
lookup(locator: Locator, version?: string): Promise<any>;
|
|
18
22
|
}
|
|
19
23
|
export {};
|
package/transpiled/discovery.js
CHANGED
|
@@ -23,24 +23,34 @@ export class Discovery extends Connector {
|
|
|
23
23
|
clearInterval(warning);
|
|
24
24
|
this.#waiting.clear();
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @param locator the component asked
|
|
28
|
+
* @param version which of its versions answers; absent, whichever of them takes the message
|
|
29
|
+
*/
|
|
30
|
+
async lookup(locator, version) {
|
|
27
31
|
const id = locator.id;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
// one per version: two of them answer under names of their own, and a process that has
|
|
33
|
+
// asked one may go on to ask the other
|
|
34
|
+
const key = version === undefined ? id : id + ':' + version;
|
|
35
|
+
if (this.#lookups[key] === undefined) {
|
|
36
|
+
const lookup = await this.#lookup(locator, version);
|
|
37
|
+
this.#lookups[key] = Promise.resolve(lookup);
|
|
31
38
|
this.depends(lookup);
|
|
32
39
|
}
|
|
33
40
|
const since = Date.now();
|
|
41
|
+
// a lookup with no version is one made outside a deployment, and saying so every five
|
|
42
|
+
// seconds would say nothing
|
|
43
|
+
const asked = version === undefined ? { component: id } : { component: id, version };
|
|
34
44
|
// the wait is unbounded by design, as a dependency may still be starting,
|
|
35
45
|
// so repeating is the only way a component stuck on one stays visible
|
|
36
46
|
const warning = setInterval(() => {
|
|
37
47
|
const waiting = Math.round((Date.now() - since) / 1000);
|
|
38
|
-
console.warn('Waiting for lookup response', {
|
|
48
|
+
console.warn('Waiting for lookup response', { ...asked, waiting });
|
|
39
49
|
}, INTERVAL);
|
|
40
50
|
warning.unref();
|
|
41
51
|
this.#waiting.add(warning);
|
|
42
52
|
try {
|
|
43
|
-
return await (await this.#lookups[
|
|
53
|
+
return await (await this.#lookups[key]).invoke();
|
|
44
54
|
}
|
|
45
55
|
finally {
|
|
46
56
|
clearInterval(warning);
|
|
@@ -1 +1 @@
|
|
|
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,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CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACtB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAExB,sFAAsF;QACtF,4BAA4B;QAC5B,MAAM,KAAK,GACT,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,CAAA;QAExE,0EAA0E;QAC1E,sEAAsE;QACtE,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;YAEvD,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;QACpE,CAAC,EAAE,QAAQ,CAAC,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,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QAClD,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"}
|
|
@@ -24,12 +24,16 @@ 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;
|
|
33
37
|
};
|
|
34
38
|
export declare class Exception {
|
|
35
39
|
readonly code: number;
|
|
@@ -83,8 +87,10 @@ export declare const TransmissionException: Derived;
|
|
|
83
87
|
export declare const EndpointException: Derived;
|
|
84
88
|
export declare const AddresseeException: Derived;
|
|
85
89
|
export declare const AbandonedException: Derived;
|
|
86
|
-
export declare const
|
|
90
|
+
export declare const DisposedException: Derived;
|
|
87
91
|
export declare const SafetyException: Derived;
|
|
92
|
+
export declare const MisuseException: Derived;
|
|
93
|
+
export declare const IrresumableException: Derived;
|
|
88
94
|
export declare const names: Record<string, string>;
|
|
89
95
|
/**
|
|
90
96
|
* Takes `unknown` because a caller has caught something rather than been handed an `Exception`.
|
package/transpiled/exceptions.js
CHANGED
|
@@ -24,12 +24,16 @@ 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
|
|
33
37
|
};
|
|
34
38
|
export class Exception {
|
|
35
39
|
code;
|
|
@@ -123,8 +127,10 @@ export const TransmissionException = derive('Transmission');
|
|
|
123
127
|
export const EndpointException = derive('Endpoint');
|
|
124
128
|
export const AddresseeException = derive('Addressee');
|
|
125
129
|
export const AbandonedException = derive('Abandoned');
|
|
126
|
-
export const
|
|
130
|
+
export const DisposedException = derive('Disposed');
|
|
127
131
|
export const SafetyException = derive('Safety');
|
|
132
|
+
export const MisuseException = derive('Misuse');
|
|
133
|
+
export const IrresumableException = derive('Irresumable');
|
|
128
134
|
export const names = swap(codes);
|
|
129
135
|
// #endregion
|
|
130
136
|
/**
|
|
@@ -168,12 +174,16 @@ const OUTCOME = {
|
|
|
168
174
|
Addressee: 'transient',
|
|
169
175
|
// what the caller gave up on may have run, and may run yet
|
|
170
176
|
Abandoned: 'transient',
|
|
177
|
+
// the tree is gone and a resume builds another, so the same context never works again
|
|
178
|
+
Disposed: 'permanent',
|
|
179
|
+
// a transition does not become an observation, and the request goes on saying it only reads
|
|
180
|
+
Safety: 'permanent',
|
|
171
181
|
// the chain is deterministic, so another attempt walks it again: a retry is another cycle
|
|
172
182
|
Loop: 'permanent',
|
|
173
183
|
// what a component did not declare, it does not declare on the next attempt either
|
|
174
184
|
Misuse: 'permanent',
|
|
175
|
-
//
|
|
176
|
-
|
|
185
|
+
// the component is refused at start, so nothing reaches it to be attempted twice
|
|
186
|
+
Irresumable: 'permanent'
|
|
177
187
|
};
|
|
178
188
|
const PERMANENT = new Set(Object.entries(OUTCOME)
|
|
179
189
|
.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,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,QAAQ,EAAE,WAAW;IACrB,4FAA4F;IAC5F,MAAM,EAAE,WAAW;IAEnB,0FAA0F;IAC1F,IAAI,EAAE,WAAW;IACjB,mFAAmF;IACnF,MAAM,EAAE,WAAW;IACnB,iFAAiF;IACjF,WAAW,EAAE,WAAW;CACzB,CAAA;AAED,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;KACpB,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,WAAW,CAAC;KAChD,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAA0B,CAAC,CAAC,CACtD,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,SAAkB;IAC1C,MAAM,IAAI,GAAI,SAAmC,EAAE,IAAI,CAAA;IAEvD,OAAO,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAClD,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,GAAG,CAAC,CAAA;IAErB,YAAmB,KAA+B;QAChD,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,qCAAqC;IAC9B,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAA;IAC3B,CAAC;IAED;;;;;;OAMG;IACI,SAAS;QACd,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC;YAAE,OAAO,CAAC,CAAA;QAElC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACrE,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QAEtB,IAA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AK,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
|
@@ -10,6 +10,7 @@ export { Encoded } from './encoded.ts';
|
|
|
10
10
|
export { Effect } from './effect.ts';
|
|
11
11
|
export { Emission } from './emission.ts';
|
|
12
12
|
export { Event } from './event.ts';
|
|
13
|
+
export { Gate } from './gate.ts';
|
|
13
14
|
export { Exposition } from './exposition.ts';
|
|
14
15
|
export { Locator } from './locator.ts';
|
|
15
16
|
export { Observation } from './observation.ts';
|
|
@@ -26,7 +27,9 @@ export { Unmanaged } from './unmanaged.ts';
|
|
|
26
27
|
export { Guard } from './guard.ts';
|
|
27
28
|
export { instance } from './instance.ts';
|
|
28
29
|
export { safe } from './safety.ts';
|
|
30
|
+
export * as deliveries from './deliveries.ts';
|
|
29
31
|
export * as entities from './entities/index.ts';
|
|
32
|
+
export * as halting from './halting.ts';
|
|
30
33
|
export * as exceptions from './exceptions.ts';
|
|
31
34
|
export * as trail from './trail.ts';
|
|
32
35
|
export * as contract from './contract/index.ts';
|
package/transpiled/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { Encoded } from './encoded.js';
|
|
|
10
10
|
export { Effect } from './effect.js';
|
|
11
11
|
export { Emission } from './emission.js';
|
|
12
12
|
export { Event } from './event.js';
|
|
13
|
+
export { Gate } from './gate.js';
|
|
13
14
|
export { Exposition } from './exposition.js';
|
|
14
15
|
export { Locator } from './locator.js';
|
|
15
16
|
export { Observation } from './observation.js';
|
|
@@ -26,7 +27,9 @@ export { Unmanaged } from './unmanaged.js';
|
|
|
26
27
|
export { Guard } from './guard.js';
|
|
27
28
|
export { instance } from './instance.js';
|
|
28
29
|
export { safe } from './safety.js';
|
|
30
|
+
export * as deliveries from './deliveries.js';
|
|
29
31
|
export * as entities from './entities/index.js';
|
|
32
|
+
export * as halting from './halting.js';
|
|
30
33
|
export * as exceptions from './exceptions.js';
|
|
31
34
|
export * as trail from './trail.js';
|
|
32
35
|
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,SA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;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,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,4 +1,5 @@
|
|
|
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';
|
|
4
5
|
import type { Remote } from '../remote.ts';
|
|
@@ -15,7 +16,11 @@ import type { Destination } from './outbox.ts';
|
|
|
15
16
|
*/
|
|
16
17
|
export interface Host {
|
|
17
18
|
/** a component of the context, by locator */
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param version which version of the component answers what it provides; absent, what the
|
|
21
|
+
* process's map says, and absent that, whichever version answers.
|
|
22
|
+
*/
|
|
23
|
+
remote(locator: Locator, source?: Source, version?: string): Promise<Remote>;
|
|
19
24
|
/** a channel of the messaging binding */
|
|
20
25
|
broadcast<L extends string = string>(channel: string, group?: string): Promise<Broadcast<L>>;
|
|
21
26
|
/** components to run inside the extension's own process */
|
|
@@ -28,6 +33,21 @@ export interface Host {
|
|
|
28
33
|
outbound(binding: string, channel: string, uris: string[]): Promise<Outbound>;
|
|
29
34
|
/** what arrives on a channel under one label */
|
|
30
35
|
inbound(binding: string, channel: string, uris: string[], label: string, sink: Inbound): Promise<Connector>;
|
|
36
|
+
/**
|
|
37
|
+
* A part of this tree a halt takes down and builds again. What is not behind one of these
|
|
38
|
+
* outlives a halt: the readiness probe does, and so does whatever answers on a port the
|
|
39
|
+
* process was already listening on.
|
|
40
|
+
*/
|
|
41
|
+
gate(build: () => Promise<Connector>): Gate;
|
|
42
|
+
/**
|
|
43
|
+
* Stops what this process does of its own accord — its gateway, its clocks, its run
|
|
44
|
+
* commands — and holds open everything it has. Nothing closes, so this is reversible.
|
|
45
|
+
*/
|
|
46
|
+
quiesce(): Promise<void>;
|
|
47
|
+
/** Undoes a quiesce: the process works again, having been rebuilt by nothing. */
|
|
48
|
+
cancel(): Promise<void>;
|
|
49
|
+
/** Stops this process for `seconds`, then builds it again. */
|
|
50
|
+
stop(seconds: number): void;
|
|
31
51
|
}
|
|
32
52
|
/**
|
|
33
53
|
* `Manifest` is a type parameter rather than an import: `@toa.io/norm` depends on core, so
|
|
@@ -65,6 +85,9 @@ export interface Factory<Manifest = unknown> {
|
|
|
65
85
|
* It connects before what the process was built with and goes after it, which is what makes it
|
|
66
86
|
* the place for something that answers for the process rather than for anything in it — the
|
|
67
87
|
* readiness probe is the one this was written for.
|
|
88
|
+
*
|
|
89
|
+
* It outlives a halt. One that must not says so by being a `Host.gate`, which is a connector
|
|
90
|
+
* like any other: the gate stays, what it holds does not.
|
|
68
91
|
*/
|
|
69
92
|
export interface Resident extends Connector {
|
|
70
93
|
/** Everything the process was built with has connected. */
|