View Source amoc_scenario behaviour (amoc v3.3.0)

Wrapper around the defined scenario

Summary

Types

The state of the scenario as returned by init/0
Unique integer ID of every actor spawned

Callbacks

start/2 is preferred over start/1. At least one of them is required.
terminate/1 is preferred over terminate/0

Functions

Applies the Scenario:init/0 callback

Applies the Scenario:start/1,2 callback

Applies the Scenario:terminate/0,1 callback

Types

-type state() :: term().
The state of the scenario as returned by init/0
-type user_id() :: pos_integer().
Unique integer ID of every actor spawned

Callbacks

-callback init() -> ok | {ok, state()} | {error, Reason :: term()}.
-callback start(user_id()) -> any().
-callback start(user_id(), state()) -> any().
start/2 is preferred over start/1. At least one of them is required.
-callback terminate() -> any().
-callback terminate(state()) -> any().
terminate/1 is preferred over terminate/0

Functions

-spec init(amoc:scenario()) -> {ok, state()} | {error, Reason :: term()}.

Applies the Scenario:init/0 callback

Runs on the controller process and spans a [amoc, scenario, init, _] telemetry event.
Link to this function

start(Scenario, Id, State)

View Source
-spec start(amoc:scenario(), user_id(), state()) -> any().

Applies the Scenario:start/1,2 callback

Either Scenario:start/1 or Scenario:start/2 must be exported from the behaviour module. if scenario module exports both functions, Scenario:start/2 is used.

Runs on the user process and spans a [amoc, scenario, user, _] telemetry event.
Link to this function

terminate(Scenario, State)

View Source
-spec terminate(amoc:scenario(), state()) -> ok | {ok, any()} | {error, Reason :: term()}.

Applies the Scenario:terminate/0,1 callback

Scenario:terminate/0 and Scenario:terminate/1 callbacks are optional. If the scenario module exports both functions, Scenario:terminate/1 is used.

Runs on the controller process and spans a [amoc, scenario, terminate, _] telemetry event.