tinyactors run
Serve one host over JSON-RPC 2.0 on standard input and output.
Usage
tinyactors run [options] [INPUT...]Experimental: the protocol may change in any release until a second client uses it. Makes one host with quickjs and adds the inputs' image: charts, a system manifest or an image. Without inputs, the client adds images. Reads JSON-RPC 2.0 messages, one per line, from standard input and answers on standard output. run.* methods are the host's calls (run.spawn, run.send, run.advanceTime, run.turn, run.addImage, ...). Every other method is core's control plane (actor.state, host.stats, ...). What actors do comes back as effect.* notifications. Each is written before the response to the request that caused it. The clock is simulated: it moves only with run.advanceTime. The end of input ends the server. run --schema writes the protocol's JSON Schema (docs/cli.md, Run).
Options
-W, --warnings-as-errorsRefuse a chart that compiles with a warning.-I, --include DIRSearchDIRfor a src that is not beside the file naming it, in the order given. Repeatable.--config FILERead the host config fromFILEas JSON (docs/host-config.md), its ioProcessors a map of type to {location}. Default: every key core's.--system IDSet the config's systemID to ID. Default: tinyactors-run.--io-processor TYPE[=LOCATION]Add an I/O processor ofTYPE, atLOCATIONwhen given, that the client serves after the config's. Repeatable.--bootSpawn the boot actors of the inputs' system manifest before the first message.--wall-start NSStart the wall clock atNSnanoseconds since the Unix epoch. Default: 0.--seed NSeed Math.random with N; 0 takes the engine's own seed, new on every run. Default: 1.--max-ops NAllow quickjs N interrupt checks per evaluation. Default: quickjs's.--memory-limit BYTESLimit quickjs's heap toBYTES. Default: quickjs's.--realm REALMSet how the charts share quickjs realms toREALM. Values: auto (shared unless globals are declared) or isolated (one per session). Default: auto.--max-message BYTESTake input lines of at mostBYTES. Default: 64 MiB.--schemaWrite the protocol's JSON Schema and exit.
Configure output formats like -f json using the shared options on the command reference.
Examples
tinyactors run order.scxmlServe a host running one chart.
tinyactors run --config shop.json order.scxml payment.scxmlServe two charts with a host config.
tinyactors run --io-processor payments --system shop order.scxml < requests.jsonl{"jsonrpc":"2.0","id":1,"result":{"session":1,"address":"tinyactors://shop/#_scxml_1"}}
{"jsonrpc":"2.0","id":2,"result":{}}
{"jsonrpc":"2.0","id":3,"result":{}}
{"jsonrpc":"2.0","method":"effect.send","params":{"batch":1,"index":0,"session":1,"type":"payments","target":"charges","event":"charge","sendid":"pay","data":{"amount":1200},"traceparent":"00-bba5ad4a1f842e59ffef8375d9ebcaca-94e8a8f3181c87c4-03","waiting":true}}
{"jsonrpc":"2.0","id":4,"result":{"status":"held","runs":1,"fuel":19,"time":0,"nextDeadline":null}}
{"jsonrpc":"2.0","id":5,"result":{}}
{"jsonrpc":"2.0","id":6,"result":{"status":"idle","runs":1,"fuel":14,"time":0,"nextDeadline":null}}
{"jsonrpc":"2.0","id":7,"result":{"value":"paid","history":{}}}
{"jsonrpc":"2.0","id":8,"result":{}}
{"jsonrpc":"2.0","method":"effect.done","params":{"batch":3,"index":0,"session":1,"name":"order-1","final":"shipped","data":{"charge":"ch_81"}}}
{"jsonrpc":"2.0","id":9,"result":{"status":"idle","runs":1,"fuel":6,"time":0,"nextDeadline":null}}
{"jsonrpc":"2.0","id":10,"result":{"session":2,"address":"tinyactors://shop/#_scxml_2"}}
{"jsonrpc":"2.0","id":11,"result":{}}
{"jsonrpc":"2.0","id":12,"result":{}}
{"jsonrpc":"2.0","method":"effect.send","params":{"batch":4,"index":0,"session":2,"type":"payments","target":"charges","event":"charge","sendid":"pay","data":{"amount":450},"traceparent":"00-7efdaa95605dfc9c4bde97c0a78eaab8-63c3721caf3ede87-03","waiting":true}}
{"jsonrpc":"2.0","id":13,"result":{"status":"idle","runs":2,"fuel":22,"time":0,"nextDeadline":30000000000}}
{"jsonrpc":"2.0","id":14,"result":{"time":30000000000,"wallNs":30000000000}}
{"jsonrpc":"2.0","method":"effect.send","params":{"batch":5,"index":0,"session":2,"type":"payments","target":"charges","event":"charge","sendid":"pay","data":{"amount":450},"traceparent":"00-7efdaa95605dfc9c4bde97c0a78eaab8-9f49d57c96da3d8f-03","waiting":true}}
{"jsonrpc":"2.0","id":15,"result":{"status":"idle","runs":2,"fuel":14,"time":30000000000,"nextDeadline":60000000000}}
{"jsonrpc":"2.0","id":16,"result":{"session":2,"segment":0,"chart":"order","parent":null,"mailbox":0,"invocations":0,"timers":[{"sendid":"deadline","event":"payment.timeout","due":60000000000}],"timersPending":1}}Serve system shop with a payments I/O processor, requests from a file.
tinyactors run --schema > run.schema.jsonWrite the protocol's JSON Schema to a file.
Exit status
0Standard input ends, or--schemahas written the schema.1An input or the config is refused at startup.3An input or standard input cannot be read, standard output cannot be written or memory runs out.