View Source amoc_controller (amoc v3.3.0)

Main controller of a node, responsible for the scenario and the users

Note that this module should be rarely used, APIs are fully exposed by amoc and amoc_dist for local or distributed environments respectively.

Summary

Types

Status of the node, note that amoc_controller is disabled for the master node
Time to wait in between spawning new users
Highest user id registered in the node
Details about the scenario currently running
Internal state of the node's controller
Number of users currently running in the node

Types

-type amoc_status() ::
    idle |
    {running, running_status()} |
    {terminating, amoc:scenario()} |
    {finished, amoc:scenario()} |
    {error, any()} |
    disabled.
Status of the node, note that amoc_controller is disabled for the master node
-type handle_call_res() :: ok | {ok, term()} | {error, term()}.
-type interarrival() :: non_neg_integer().
Time to wait in between spawning new users
-type last_user_id() :: non_neg_integer().
Highest user id registered in the node
-type running_status() ::
    #{scenario := amoc:scenario(),
      currently_running_users := user_count(),
      highest_user_id := last_user_id()}.
Details about the scenario currently running
-type state() ::
    #state{scenario :: amoc:scenario() | undefined,
           last_user_id :: last_user_id(),
           status :: idle | running | terminating | finished | {error, any()} | disabled,
           scenario_state :: any(),
           create_users :: [amoc_scenario:user_id()],
           tref :: timer:tref() | undefined}.
Internal state of the node's controller
-type user_count() :: non_neg_integer().
Number of users currently running in the node

Functions

Link to this function

add_users(StartId, EndId)

View Source
-spec add_users(amoc_scenario:user_id(), amoc_scenario:user_id()) -> ok | {error, term()}.
-spec disable() -> ok | {error, term()}.
-spec get_status() -> amoc_status().
Link to this function

remove_users(Count, ForceRemove)

View Source
-spec remove_users(user_count(), boolean()) -> {ok, user_count()}.
Link to this function

start_scenario(Scenario, Settings)

View Source
-spec start_scenario(amoc:scenario(), amoc_config:settings()) -> ok | {error, term()}.
-spec stop_scenario() -> ok | {error, term()}.
Link to this function

update_settings(Settings)

View Source
-spec update_settings(amoc_config:settings()) -> ok | {error, term()}.