@toa.io/boot 1.0.0-alpha.32 → 1.0.0-alpha.320
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 +306 -0
- package/package.json +11 -8
- package/src/atom.js +41 -0
- package/src/atomicity.js +11 -0
- package/src/bindings/broadcast.js +3 -6
- package/src/bindings/constants.js +1 -3
- package/src/bindings/consume.js +18 -6
- package/src/bindings/emit.js +3 -6
- package/src/bindings/factory.js +5 -9
- package/src/bindings/inbound.js +11 -0
- package/src/bindings/index.js +7 -13
- package/src/bindings/outbound.js +10 -0
- package/src/bindings/produce.js +56 -17
- package/src/bindings/receive.js +3 -6
- package/src/bridge.js +22 -16
- package/src/call.js +28 -9
- package/src/cascade.js +16 -10
- package/src/component.js +98 -32
- package/src/composition.js +106 -15
- package/src/context.js +7 -8
- package/src/contract.js +11 -12
- package/src/emission.js +21 -14
- package/src/env.js +19 -12
- package/src/events.js +27 -0
- package/src/extensions/aspects.js +4 -8
- package/src/extensions/component.js +4 -8
- package/src/extensions/context.js +4 -8
- package/src/extensions/destinations.js +27 -0
- package/src/extensions/emitter.js +7 -9
- package/src/extensions/index.js +10 -19
- package/src/extensions/instances.js +2 -4
- package/src/extensions/load.js +7 -7
- package/src/extensions/manage.js +15 -0
- package/src/extensions/receiver.js +5 -9
- package/src/extensions/resolve.js +62 -13
- package/src/extensions/storage.js +6 -9
- package/src/extensions/tenants.js +5 -9
- package/src/guards.js +20 -0
- package/src/host.js +29 -0
- package/src/inbox.js +12 -0
- package/src/index.js +28 -34
- package/src/manifest.js +78 -36
- package/src/manifest.test.js +85 -8
- package/src/map.js +108 -0
- package/src/operation.js +26 -14
- package/src/outbox.js +22 -0
- package/src/rc.js +5 -0
- package/src/receivers.js +53 -23
- package/src/remote.js +41 -22
- package/src/rendering.js +50 -0
- package/src/span.js +19 -0
- package/src/storage.js +50 -16
- package/src/storage.test.js +57 -0
- package/src/workload.js +281 -0
- package/src/workload.test.js +321 -0
- package/types/bindings.d.ts +6 -2
- package/types/index.d.ts +62 -10
- package/types/manifest.d.ts +5 -4
- package/src/discovery.js +0 -43
- package/src/exposition.js +0 -17
package/types/index.d.ts
CHANGED
|
@@ -1,21 +1,73 @@
|
|
|
1
|
-
import * as core from '@toa.io/core'
|
|
2
|
-
import * as
|
|
1
|
+
import type * as core from '@toa.io/core'
|
|
2
|
+
import type * as types from '@toa.io/core/types'
|
|
3
|
+
import type * as norm from '@toa.io/norm/types'
|
|
4
|
+
import * as composition from './composition.d.ts'
|
|
3
5
|
|
|
4
|
-
export * as bindings from './bindings'
|
|
6
|
+
export * as bindings from './bindings.d.ts'
|
|
5
7
|
|
|
6
|
-
export async function
|
|
8
|
+
export async function manifest(
|
|
9
|
+
path: string,
|
|
10
|
+
options?: composition.Options
|
|
11
|
+
): Promise<norm.Manifest>
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
/** What this process was given about the components it calls. */
|
|
14
|
+
export namespace map {
|
|
15
|
+
/** the file to read it from, or the map itself */
|
|
16
|
+
function use(value: string | Record<string, core.Contract> | undefined): void
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
/** what this process composes, stated by the boot that composes it */
|
|
19
|
+
function compose(manifests: norm.Manifest[]): Promise<void>
|
|
20
|
+
|
|
21
|
+
/** forgets what this process composed */
|
|
22
|
+
function forget(): void
|
|
23
|
+
|
|
24
|
+
function contract(id: string): Promise<core.Contract | undefined>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function composition(
|
|
28
|
+
paths: string[],
|
|
29
|
+
options?: composition.Options
|
|
30
|
+
): Promise<core.Connector>
|
|
31
|
+
|
|
32
|
+
export async function remote(
|
|
33
|
+
locator: core.Locator,
|
|
34
|
+
source?: types.Source
|
|
35
|
+
): Promise<core.Remote>
|
|
36
|
+
|
|
37
|
+
export async function receive<T = any>(
|
|
11
38
|
label: string,
|
|
12
|
-
receiver: Receiver
|
|
39
|
+
receiver: Receiver
|
|
13
40
|
): Promise<core.Connector>
|
|
14
41
|
|
|
15
|
-
export async function receive<T = any>
|
|
42
|
+
export async function receive<T = any>(
|
|
16
43
|
label: string,
|
|
17
44
|
group: string | undefined,
|
|
18
|
-
receiver: Receiver
|
|
45
|
+
receiver: Receiver
|
|
19
46
|
): Promise<core.Connector>
|
|
20
47
|
|
|
21
|
-
type Receiver = { receive: (message:
|
|
48
|
+
type Receiver = { receive: (message: types.Message<T>) => void | Promise<void> }
|
|
49
|
+
|
|
50
|
+
export function host(): types.extensions.Host
|
|
51
|
+
|
|
52
|
+
/** A process, as a connector: what the command built, and what the extensions keep in one. */
|
|
53
|
+
export class Workload extends core.Connector {
|
|
54
|
+
constructor(build: (workload: Workload) => Promise<core.Connector>)
|
|
55
|
+
|
|
56
|
+
/** A part of this process a halt takes down and builds again. */
|
|
57
|
+
gate(build: () => Promise<core.Connector>): core.Gate
|
|
58
|
+
|
|
59
|
+
/** Whether what a halt takes down is up. */
|
|
60
|
+
running(): boolean
|
|
61
|
+
|
|
62
|
+
/** Whether this process is quiet: it does nothing of its own accord and holds everything. */
|
|
63
|
+
quiescent(): boolean
|
|
64
|
+
|
|
65
|
+
/** Stops what this process does of its own accord, holding open everything it has. */
|
|
66
|
+
quiesce(): Promise<void>
|
|
67
|
+
|
|
68
|
+
/** Undoes a quiesce. */
|
|
69
|
+
cancel(): Promise<void>
|
|
70
|
+
|
|
71
|
+
/** Stops this process for `seconds`, then builds it again. */
|
|
72
|
+
stop(seconds: number): void
|
|
73
|
+
}
|
package/types/manifest.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _norm from '@toa.io/norm/types'
|
|
2
|
-
import * as _composition from './composition'
|
|
2
|
+
import * as _composition from './composition.d.ts'
|
|
3
3
|
|
|
4
4
|
declare namespace toa.boot {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type Manifest = (
|
|
6
|
+
path: string,
|
|
7
|
+
options?: _composition.Options
|
|
8
|
+
) => Promise<_norm.Component>
|
|
8
9
|
}
|
package/src/discovery.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { Discovery, Exposition } = require('@toa.io/core')
|
|
4
|
-
|
|
5
|
-
const boot = require('./index')
|
|
6
|
-
|
|
7
|
-
let promise
|
|
8
|
-
let instance = null
|
|
9
|
-
|
|
10
|
-
const discovery = async () => {
|
|
11
|
-
if (instance === null) {
|
|
12
|
-
instance = new Discovery(lookup)
|
|
13
|
-
promise = instance.connect()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
await promise
|
|
17
|
-
|
|
18
|
-
return instance
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const lookup = async (locator) => {
|
|
22
|
-
const call = boot.call(locator, ENDPOINT, { bindings: BINDINGS })
|
|
23
|
-
|
|
24
|
-
await call.connect()
|
|
25
|
-
|
|
26
|
-
return call
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const expose = async (manifest) => {
|
|
30
|
-
const exposition = new Exposition(manifest.locator, manifest)
|
|
31
|
-
const operations = { [ENDPOINT]: { bindings: BINDINGS } }
|
|
32
|
-
const producers = boot.bindings.produce(exposition, operations)
|
|
33
|
-
|
|
34
|
-
await Promise.all(producers.map((producer) => producer.connect()))
|
|
35
|
-
|
|
36
|
-
return producers
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const BINDINGS = ['@toa.io/bindings.amqp']
|
|
40
|
-
const ENDPOINT = '.lookup'
|
|
41
|
-
|
|
42
|
-
exports.discovery = discovery
|
|
43
|
-
exports.expose = expose
|
package/src/exposition.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { Exposition, Locator } = require('@toa.io/core')
|
|
4
|
-
|
|
5
|
-
const boot = require('./index')
|
|
6
|
-
|
|
7
|
-
const exposition = async (manifest) => {
|
|
8
|
-
const locator = new Locator('', '')
|
|
9
|
-
const exposition = new Exposition(locator, manifest)
|
|
10
|
-
const producers = boot.bindings.expose(exposition)
|
|
11
|
-
|
|
12
|
-
await Promise.all(producers.map((producer) => producer.connect()))
|
|
13
|
-
|
|
14
|
-
return producers
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.exposition = exposition
|