rngo sim

Runs a simulation. In particular, it:

  1. builds a simulation spec
  2. posts it to the Create Simulation API endpoint
  3. streams the data from the Stream Simulation endpoint
  4. imports the data into the appropriate systems

Building a Simulation Spec

rngo sim builds a simulation spec based upon the contents of the local.rngo directory.

The base of the spec is the contents of .rngo/spec.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/entities directory. For example, if there was a file at.rngo/entities/USER.yml with the following value:

stream:
  type: object
  properties:
    id:
      type: id.integer
    name:
      type: person.name
          

It will be inserted into the spec like this:

seed: 1
entities:
  USER:
    stream:
      type: object
      properties:
        id:
          type: id.integer
        name:
          type: person.name

If the path already exists in the base spec, the .rngo/entities file be ignored. An analogous process happens for the files in the .rngo/systems directory.

This entire step is skipped if the--spec flag is set, like this:

rngo sim --spec spec.yml

In this case, the content of thespec.yml file will be used as is.

Importing Data

The Stream Simulation API endpoint delivers simulation data as a single stream of SSEs. rngo sim will route each event to the appropriate system.

Consider the following excerpt from a spec:

systems:
  db1:
    output:
      type: sql
    import:
      command: sqlite3 db1.sqlite
entities:
  invoices:
    system:
      type: db1
    stream:
      type: object
      ...

In this case, all SSEs for theinvoices entity will be piped into thesqlite3 db1.sqlite command

You can specify a raw output for an entity, like this:

entities:
  orders:
    output:
      type: json
    stream:
      type: object
      ...

In this case (which is also the default), rngo sim will route to a default system - in this case, it is effectively something like:

output:
  type: json
import:
  command: cat > .rngo/simulations/hLpmFg0qFW2idopyd8NAq/orders.jsonl

You can set the--stdout boolean flag, e.g.:

rngo sim --stdout

This will skip system routing and write all event values to stdout.