This commit is contained in:
+21
-8
@@ -59,15 +59,25 @@ it exits. After 5 seconds, it kills the instance.
|
||||
|
||||
## Filesystem
|
||||
|
||||
Each instance sees three folders:
|
||||
The world folder is the foundation of every instance's filesystem:
|
||||
|
||||
| Path | Access | Contents |
|
||||
| --- | --- | --- |
|
||||
| `/data` | read-write by its actor; readable by every actor | the actor's state |
|
||||
| `/public` | read-write | the files that the actor publishes |
|
||||
| `/actor` | read-only | the `actor/` folder of the world |
|
||||
| `/` | read-write by every actor | the whole world folder |
|
||||
| `/data` | read-write | alias for the actor's state folder |
|
||||
| `/public` | read-write | alias for the actor's published files |
|
||||
| `/actor` | read-write by every actor | the `actor/` folder of the world |
|
||||
|
||||
An actor can write only its own `/data`, but can read every actor's `/data` through `/actor/<id>/data/`. `/data` is not private: any unprotected secret file there is readable by every actor.
|
||||
Every actor can read and write every file in the world, including other actors'
|
||||
`/actor/<id>/data/` and `/actor/<id>/public/`. Nothing there is private.
|
||||
Creating a folder in the world makes it visible to running actors immediately:
|
||||
`/config`, `/docs`, `/www`, and `/skills` need no new mounts or host restart.
|
||||
New worlds include an empty `/config` for global configuration by convention;
|
||||
existing worlds can simply create it. Keep secrets out of global configuration.
|
||||
|
||||
Candidate instances see the same writable world root. Their `/public` and
|
||||
`/data` aliases still point to scratch copies, and network access remains off;
|
||||
absolute world paths are not isolated from the live world.
|
||||
|
||||
`/actor/<id>/` holds everything about an actor: `actor.wasm`, `actor.json`
|
||||
(installed version, running, subscriptions, tapped, watches), `source/`, `public/`, `data/`,
|
||||
@@ -131,12 +141,15 @@ the request: the request's `type` in past tense (`spawned`, `upgraded`,
|
||||
| `remove` | `actor` | stop the actor (normal shutdown), then delete its whole folder `/actor/<id>/` (all versions, `data/`, `public/`, logs); answer `{"type": "removed", "actor"}`. Messages to it are then undeliverable, and the ID can be spawned again. An unknown actor or a native one (`broker`, `console`, `cargo`, `fs`) is an `error` |
|
||||
| `subscribe`, `unsubscribe` | `actor` | receive (or not) what `actor` publishes |
|
||||
| `tap`, `untap` | | receive (or not) a copy of every message the broker routes |
|
||||
| `watch`, `unwatch` | `path` | receive (or not) `fs_changed` for every change of `path` or anything under it; answer `{"type": "watching" \| "unwatched", "path"}` with the path as an `/actor/...` path |
|
||||
| `watch`, `unwatch` | `path` | receive (or not) `fs_changed` for every change of `path` or anything under it; answer `{"type": "watching" \| "unwatched", "path"}` with the path as an absolute world path |
|
||||
| `exit` | | answer `exiting`, stop every actor, and end the `sausage` process with exit code 75 (a wrapper like `nix run .#loop` starts it again, updated) |
|
||||
|
||||
**Headless.** `sausage run --headless [dir]` (or `sausage --headless`, or `SAUSAGE_HEADLESS=1`) turns the console input off: the host does not read stdin, so end of input (`/dev/null`) does not stop the world. `nix run .#loop -- --headless <world>` passes it through the loop. It runs until SIGTERM or SIGINT (stops every actor, exit code 0) or a broker `exit` request (exit code 75, as above). Without the flag, EOF on stdin or `/quit` ends the host.
|
||||
|
||||
Paths are `/actor/...`, or the sender's `/public/...` or `/data/...`.
|
||||
Paths are absolute world paths, or the sender's `/public/...` or `/data/...`
|
||||
aliases. Native senders (such as the console) can also supply absolute host
|
||||
paths; apart from the three existing aliases (`/actor`, `/public`, `/data`),
|
||||
these retain their host meaning.
|
||||
|
||||
**Taps.** After `tap`, the sender gets a copy of every message that the
|
||||
broker routes (direct messages, replies, and publishes, between any actors,
|
||||
@@ -176,7 +189,7 @@ change of `path` or a path under it (`/actor/a` covers `/actor/a/x`, not
|
||||
- Events come from `fs`. Like tap copies, they are not routed, a full
|
||||
mailbox drops them, and they never block the writer. Never answer them.
|
||||
- If the OS drops events, every watcher gets one
|
||||
`{"type": "fs_changed", "path": "/actor", "op": "rescan"}`: anything may
|
||||
`{"type": "fs_changed", "path": "/", "op": "rescan"}`: anything may
|
||||
have changed.
|
||||
- A watch is saved in `actor.json` (`"watches": [...]`) and survives
|
||||
restarts and upgrades. `unwatch` with the same path ends it.
|
||||
|
||||
Reference in New Issue
Block a user