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:
:integergenerates a random integer between:minand:max(defaults tomin = 0andmax = 100).:realgenerates a random float between:minand:max(defaults tomin = 0andmax = 1).:booleangeneratestruewith 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,:realand:boolean:min- Used with:integerand:realtypes to define a min value.:max- Used with:integerand:realtypes to define a max value.:p- Used with:booleantype to define the probability of the generator returningtrue. The value must be>= 0and<= 1.:delay_ms- If notnil, the block will waitdelay_msbefore emitting a new sample