amoc_scenario behaviour (amoc v4.1.0)

View Source

Wrapper around the defined scenario

Summary

Types

The state of the scenario as returned by init/0

Unique integer ID of every actor spawned

Functions

Applies the Scenario:init/0 callback

Applies the Scenario:start/1,2 callback

Applies the Scenario:terminate/0,1 callback

Types

state/0

-type state() :: term().

The state of the scenario as returned by init/0

user_id/0

-type user_id() :: pos_integer().

Unique integer ID of every actor spawned

Callbacks

init/0

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

start/1

(optional)
-callback start(user_id()) -> any().

start/2

(optional)
-callback start(user_id(), state()) -> any().
start/2 is preferred over start/1. At least one of them is required.

terminate/0

(optional)
-callback terminate() -> any().

terminate/1

(optional)
-callback terminate(state()) -> any().
terminate/1 is preferred over terminate/0

Functions

init(Scenario)

-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.

start(Scenario, Id, State)

-spec start(amoc:scenario(), user_id(), state()) -> term().

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.

terminate(Scenario, State)

-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.