rngo sim run
Runs a simulation. In particular, it:
- builds a simulation based upon the
.rngodirectory - syncs it to the API via the Set Simulation endpoint
- streams the effects from the API via the Stream Simulation Run endpoint
- routes the effects to the appropriate systems
Building a Simulation
rngo sim builds a simulation based upon the contents of the local.rngo directory.
The base of the simulation is the contents of .rngo/config.yml. If this file doesn't exist, the base will be an empty spec with a seed of 1.
From there, it will merge in each file under the .rngo/effects directory. For example, if there was a file at.rngo/effects/user.create.yml with the following value:
schema:
type: object
properties:
id:
type: id.integer
name:
type: person.nameIt will be inserted into the simulation like this:
seed: 1
entities:
user.create:
schema:
type: object
properties:
id:
type: id.integer
name:
type: person.nameIf the path already exists in .rngo/config.yml, the .rngo/effects file will be ignored. An analogous process happens for the files in the.rngo/systems directory.
This entire step is skipped if the --file flag is set, like this:
rngo sim run --file sim.ymlIn this case, the content of the sim.yml file will be used as is.
Applying Effects
The Stream Simulation Run API endpoint returns a stream of events. rngo sim run will route each effect event to the appropriate system.
Consider the following excerpt from a simulation:
systems:
db1:
format:
type: sql
import:
command: sqlite3 db1.sqlite
effects:
invoice.create:
system: db1
schema:
type: object
...In this case, all events for the invoice.create effect will be piped into the sqlite3 db1.sqlite command.
You can specify a raw output for an effect, like this:
entities:
orders.create:
format:
type: json
schema:
type: object
...rngo sim run will route to a default system — in this case, it is effectively something like:
output:
type: json
import:
command: cat > .rngo/simulations/hLpmFg0qFW2idopyd8NAq/orders.jsonlYou can set the --stdout boolean flag, e.g.:
rngo sim run --stdoutThis will skip system routing and write all event values to stdout.