View Source Avrogen.Util.Random.Constructors (avrogen v0.8.5)

Provides functions that return "constructor functions". A constructor function is a function that expects a rand_state and optional parameters, and, on invocation, returns an updated rand_state and a randomly generated value.

The functions in this module are basically 'lazy' wrappers around eager functions in the parent module.

Thanks to this 'laziness', we can specify lists of alternative constructor functions, from which we can randomly choose an element for evaluation (without forcing all elements to be evaluated up front).

Summary

Types

@type constructor_fun() ::
  (Avrogen.Util.Random.rand_state() ->
     {Avrogen.Util.Random.rand_state(), any()})
@type constructor_list() ::
  {atom(), constructor_fun()} | {atom(), [constructor_fun()]}

Functions

@spec boolean() :: constructor_fun()
@spec date(Keyword.t()) :: constructor_fun()
@spec datetime(Keyword.t()) :: constructor_fun()
@spec decimal(Keyword.t()) :: constructor_fun()
@spec enum_value(atom()) :: constructor_fun()
@spec float(Keyword.t()) :: constructor_fun()
Link to this function

instantiate(rand_state, struct_name, constructors)

View Source

Instantiates a struct with random values as per the given constructors list. Returns the updated rand_state and the instantiated struct.

@spec integer(Keyword.t()) :: constructor_fun()
Link to this function

list(constructor_fun, max_length \\ 10)

View Source
@spec list(constructor_fun(), integer()) :: constructor_fun()
Link to this function

map(value_constructor, opts \\ [])

View Source
@spec nothing() :: constructor_fun()
@spec string(Keyword.t()) :: constructor_fun()
@spec time(Keyword.t()) :: constructor_fun()