The GeneratorActor
is a Coral Actor that enables the generation of data based on a JSON input template. The JSON input template defines the fields and structure of the JSON object to emit, and the values of the JSON template define the distribution of the data to generate.
The GeneratorActor has "type": "generator"
. The params
value is a JSON object with the following fields:
field | type | required | description |
---|---|---|---|
format |
JObject | yes | The format of the object to return. The complete object will be returned as the top-level JSON object. The fields provide the distribution of the data to generate. |
timer : rate |
Int | yes | The number of objects to generate per second. |
timer : times |
Int | no | The total number of objects to generate. After this number is reached, output is stopped. |
timer : delay |
Int | no | The number of seconds to wait until the first object is emitted. Not required, if no delay is given, a delay of 0 seconds is used. |
The GeneratorActor
currently has three different generator functions:
name | format | description | example |
---|---|---|---|
Normal | N(mu, sigma) |
Samples a value from the normal distribution as given by the mu (average) and sigma (standard deviation) parameters. | N(100.2,53.8) |
Uniform | U(max) |
Samples a value from a uniform distribution from 0 to max |
U(42) |
List choice | ['s1','s2','s3'] |
Samples a value uniformly from any of the given string choices s1 , s2 or s3 . |
['a','b','c'] |
This will create a GeneratorActor that emits 10 objects per second, of which a couple of examples follow:
Next, the following object may be emitted:
Because the delay is set to 1 second, it waits 1 second before emitting the first object. When it has emitted 100 objects, it stops.
The GeneratorActor
is not triggered by external events, but rather generates data autonomously.
The GeneratorActor
emits data based on the rate
parameter. When rate
is set to 10, it emits an object every 100 milliseconds.
The state of the GeneratorActor
returns the following fields:
field | type | description |
---|---|---|
rate |
Int | The number of objects per second that will be emitted. |
times |
Int | The maximum number of objects to emit. |
delay |
Int | The number of seconds that the actor has waited before emitting the first object. |
format |
JObject | The format that was specified in the constructor. |
count |
Int | The total number of objects emitted until now. |
The GeneratorActor
does not collect state from other actors.
The GeneratorActor
periodically emits data according to its rate
, times
and delay
settings.