Astarte.Flow.Blocks.RandomProducer (astarte_flow v0.1.0)
Producer module that generates random messages of a specific type with a fixed key. The supported types are :integer
, :real
and :boolean
.
The data generated for each type is the following:
:integer
generates a random integer between:min
and:max
(defaults tomin = 0
andmax = 100
).:real
generates a random float between:min
and:max
(defaults tomin = 0
andmax = 1
).:boolean
generatestrue
with probability:p
(defaults top = 0.5
), otherwisefalse
.
The message timestamp will be generated with DateTime.utc_now().
Link to this section Summary
Functions
Starts the RandomProducer
.
Link to this section Types
Link to this type
boolean_option()
@type boolean_option() :: {:p, float()}
Link to this type
integer_option()
Link to this type
option()
@type option() :: {:key, String.t()} | {:type, supported_types()} | {:delay_ms, integer()} | integer_option() | real_option() | boolean_option()
Link to this type
options()
@type options() :: [option()]
Link to this type
real_option()
Link to this type
supported_types()
@type supported_types() :: :integer | :real | :boolean
Link to this section Functions
Link to this function
start_link(opts)
@spec start_link(options()) :: GenServer.on_start()
Starts the RandomProducer
.
options
Options
:key
(required) - A unicode string that will be used as key in the generated messages:type
(required) - The type of data that will be generated. Supported types are:integer
,:real
and:boolean
:min
- Used with:integer
and:real
types to define a min value.:max
- Used with:integer
and:real
types to define a max value.:p
- Used with:boolean
type to define the probability of the generator returningtrue
. The value must be>= 0
and<= 1
.:delay_ms
- If notnil
, the block will waitdelay_ms
before emitting a new sample