@toa.io/userland 1.0.0-alpha.305 → 1.0.0-alpha.307
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 +18 -0
- package/package.json +6 -6
- package/stage/src/index.js +2 -0
- package/stage/src/map.js +15 -0
- package/stage/src/quiescence.js +16 -0
- package/stage/src/shutdown.js +4 -0
- package/stage/src/workload.js +41 -5
- package/stage/test/boot.mock.js +1 -0
- package/stage/types/index.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.307](https://github.com/toa-io/toa/compare/v1.0.0-alpha.306...v1.0.0-alpha.307) (2026-09-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @toa.io/userland
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.0.0-alpha.306](https://github.com/toa-io/toa/compare/v1.0.0-alpha.305...v1.0.0-alpha.306) (2026-09-14)
|
|
15
|
+
|
|
16
|
+
* feat(boot)!: a process can be halted and come back ([7196fa5](https://github.com/toa-io/toa/commit/7196fa51a9c882e84c3767a4fdd329fd2df319f5))
|
|
17
|
+
|
|
18
|
+
### BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
* `Host` gains `gate` and `halt`, and `Factory.service` may answer a gate. An
|
|
21
|
+
extension that gates nothing keeps its connections through a halt.
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
# [1.0.0-alpha.305](https://github.com/toa-io/toa/compare/v1.0.0-alpha.304...v1.0.0-alpha.305) (2026-09-13)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @toa.io/userland
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/userland",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.307",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa development kit",
|
|
6
6
|
"homepage": "https://toa.io",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@toa.io/boot": "1.0.0-alpha.
|
|
36
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
35
|
+
"@toa.io/boot": "1.0.0-alpha.307",
|
|
36
|
+
"@toa.io/core": "1.0.0-alpha.306",
|
|
37
37
|
"@toa.io/generic": "1.0.0-alpha.304",
|
|
38
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
38
|
+
"@toa.io/norm": "1.0.0-alpha.307",
|
|
39
39
|
"@toa.io/schemas": "1.0.0-alpha.304",
|
|
40
|
-
"@toa.io/storages.null": "1.0.0-alpha.
|
|
40
|
+
"@toa.io/storages.null": "1.0.0-alpha.306"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "d5f4b2e97e315ba8ab657039d0407565c96e34bc"
|
|
43
43
|
}
|
package/stage/src/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { manifest } from './manifest.js'
|
|
2
|
+
export { map } from './map.js'
|
|
2
3
|
export { component } from './component.js'
|
|
3
4
|
export { composition, composition as compose } from './composition.js'
|
|
4
5
|
export { workload } from './workload.js'
|
|
5
6
|
export { service as serve } from './service.js'
|
|
6
7
|
export { remote } from './remote.js'
|
|
8
|
+
export { halt, restore } from './quiescence.js'
|
|
7
9
|
export { shutdown } from './shutdown.js'
|
package/stage/src/map.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as boot from '@toa.io/boot'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which version of each component a lookup made in this process asks for.
|
|
5
|
+
*
|
|
6
|
+
* A composition staged here is given none unless a test states one, and a lookup with no version
|
|
7
|
+
* goes to the name every version of a component answers on — which is what a run outside a
|
|
8
|
+
* deployment gets.
|
|
9
|
+
*
|
|
10
|
+
* @param {Record<string, string> | undefined} versions
|
|
11
|
+
* @returns {void}
|
|
12
|
+
*/
|
|
13
|
+
export const map = (versions) => {
|
|
14
|
+
boot.map.use(versions)
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { state } from './state.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stops what everything staged does of its own accord, holding every connection open — what a
|
|
5
|
+
* process does when it is told to go quiet. A component's `stop` run command runs here.
|
|
6
|
+
*/
|
|
7
|
+
export const halt = async () => {
|
|
8
|
+
for (const composition of state.compositions) await composition.halt()
|
|
9
|
+
for (const workload of state.workloads) await workload.halt()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Starts it again, running the `resume` command. */
|
|
13
|
+
export const restore = async () => {
|
|
14
|
+
for (const composition of state.compositions) await composition.restore()
|
|
15
|
+
for (const workload of state.workloads) await workload.restore()
|
|
16
|
+
}
|
package/stage/src/shutdown.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { state } from './state.js'
|
|
2
|
+
import { map } from './map.js'
|
|
2
3
|
|
|
3
4
|
/** @type {toa.stage.Shutdown} */
|
|
4
5
|
export const shutdown = async () => {
|
|
@@ -17,5 +18,8 @@ export const shutdown = async () => {
|
|
|
17
18
|
|
|
18
19
|
await Promise.all(disconnections)
|
|
19
20
|
|
|
21
|
+
// whatever a test stated is not carried into the next one
|
|
22
|
+
map(undefined)
|
|
23
|
+
|
|
20
24
|
state.reset()
|
|
21
25
|
}
|
package/stage/src/workload.js
CHANGED
|
@@ -1,15 +1,51 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'
|
|
2
|
+
import { pathToFileURL } from 'node:url'
|
|
1
3
|
import * as boot from '@toa.io/boot'
|
|
4
|
+
import { Connector } from '@toa.io/core'
|
|
5
|
+
import { shortcuts } from '@toa.io/norm'
|
|
2
6
|
import { state } from './state.js'
|
|
3
7
|
|
|
8
|
+
// a shortcut resolves to a package name, which is not a path
|
|
9
|
+
const require = createRequire(import.meta.url)
|
|
10
|
+
|
|
11
|
+
/** The services, made against this process rather than against no process. */
|
|
12
|
+
const create = async (references, workload) => {
|
|
13
|
+
const services = []
|
|
14
|
+
|
|
15
|
+
for (const reference of references) {
|
|
16
|
+
const path = shortcuts.resolve(reference)
|
|
17
|
+
const { Factory } = await import(pathToFileURL(require.resolve(path)).href)
|
|
18
|
+
const service = await new Factory(boot.host(workload)).service()
|
|
19
|
+
|
|
20
|
+
if (service !== null) services.push(service)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return services
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
/**
|
|
5
|
-
* A process, as `toa compose` runs one: the composition
|
|
6
|
-
*
|
|
27
|
+
* A process, as `toa compose` runs one: the composition behind a gate, whatever services it
|
|
28
|
+
* was told to run beside it, and whatever the extensions keep in a process — the readiness
|
|
29
|
+
* probe, the ear a halt arrives at.
|
|
7
30
|
*
|
|
8
31
|
* `composition` is the other way to boot the same components, and the difference is the point
|
|
9
|
-
* of this one: what belongs to a process is here and not there.
|
|
32
|
+
* of this one: what belongs to a process is here and not there. So is what a halt takes,
|
|
33
|
+
* which is why a service that has to be halted is run from here rather than staged apart.
|
|
10
34
|
*/
|
|
11
|
-
export const workload = async (paths, options) => {
|
|
12
|
-
const workload = new boot.Workload(async () =>
|
|
35
|
+
export const workload = async (paths, options, services = []) => {
|
|
36
|
+
const workload = new boot.Workload(async (workload) => {
|
|
37
|
+
const composition = workload.gate(
|
|
38
|
+
async () => await boot.composition(paths, options)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
if (services.length === 0) return composition
|
|
42
|
+
|
|
43
|
+
const root = new Connector()
|
|
44
|
+
|
|
45
|
+
root.depends([composition, ...(await create(services, workload))])
|
|
46
|
+
|
|
47
|
+
return root
|
|
48
|
+
})
|
|
13
49
|
|
|
14
50
|
await workload.connect()
|
|
15
51
|
|
package/stage/test/boot.mock.js
CHANGED
|
@@ -8,6 +8,7 @@ const connector = () => ({
|
|
|
8
8
|
link: mock.fn()
|
|
9
9
|
})
|
|
10
10
|
|
|
11
|
+
export const map = { use: mock.fn() }
|
|
11
12
|
export const manifest = mock.fn(async () => generate())
|
|
12
13
|
export const component = mock.fn(async () => connector())
|
|
13
14
|
export const composition = mock.fn(async () => connector())
|
package/stage/types/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ import type * as _boot from '@toa.io/boot'
|
|
|
5
5
|
|
|
6
6
|
export function manifest(path: string): Promise<_norm.Component>
|
|
7
7
|
|
|
8
|
+
/** which version of each component a lookup made in this process asks for */
|
|
9
|
+
export function map(versions: Record<string, string> | undefined): void
|
|
10
|
+
|
|
8
11
|
export function component(path: string): Promise<_core.Component>
|
|
9
12
|
|
|
10
13
|
export function composition(
|