rngo

Reference

Expressions

Expressions may be used in two contexts:

  1. value - when using the rngo.value JSON schema extension to generate realistic values
  2. rate - when specifying a dynamic event rate in the stream rate field
  3. duration - when setting the start and end of the simution.

Context

Each context has entrypoint methods that may be referenced in expressions without explicit qualification.

Value

MethodReturnsNotes
.streamsObject[Stream]A map of every stream in the workspace, keyed by its name.
.dataDataCatalogA map of all enums provided by rngo. See Enums for more.
.simSimulationThe simulation state when the value is being generated.

Rate

MethodReturnsNotes
.simSimulationThe simulation state when the rate is being sampled.

Duration

MethodArgsReturnsNotes
.daysAgodays: NumberTimestampReturns the number of days prior to the time when the expression is evaluated.
.yearsAgoyears: NumberTimestampReturns the number of years prior to the time when the expression is evaluated.
.daysFromNowdays: NumberTimestampReturns the number of days after the time when the expression is evaluated.
.yearsFromNowyears: NumberTimestampReturns the number of years after the time when the expression is evaluated.

API

DataCatalog

Categorized data sets used to further narrow valid stream output beyond the JSON Schema definition.

See Data Catalog for more.

Stream

The state of a stream at the current point in the simulation. Stream extends Set so you can also call Set methods on a Stream instance.

Example: The set of all id values in the posts stream

stream.posts.last.id
MethodReturnsNotes
.firstValue | NullThe first value generated by the stream, if any.
.lastValue | NullThe last value generated by the stream, if any.

Set

A collection of Values, that is potentially very large. Commonly used to specify rngo.value in a schema.

Example: A random value in the fullName enum

enum.fullName.random
MethodReturnsNotes
.randomValue | NullReturns a random value from the set, or null if empty.
.uniqueValue | NullReturns a random value from the set that has not been previously returned. If all values have been returned, or if the set is empty, returns null.

Simulation

Information about the current state of the simulation.

Example: The current time in the simulation

sim.now
MethodReturnsNotes
.nowTimestampThe current UTC wall clock time within the simulation.
.offsetNumberThe integer number of milliseconds since the simulation started.

Data Types

Value

Any value generated by a stream. It is a recursive union type with any of the following variants:

Array

An ordered collection, generic over type T.

MethodReturnsNotes
[{index}]T | NullReturns the value at the specified integer index, if ones exists.

Object

An associated array, generic over value type T.

MethodReturnsNotes
.{property}T | NullReturns the value of a named property, if it exists.

Boolean

Either true or false.

Null

A value that represents the absence of a value.

Number

An integer or floating point number.

String

A sequence of Unicode characters.

Timestamp

An ISO 8901 UTC timestamp.

MethodReturnsNotes
.stringStringThe ISO 8901 representation of the timestamp.
Previous
Data Catalog