amoc_controller (amoc v4.1.0)

View Source

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

Highest user id registered in the node

Details about the scenario currently running

Internal state of the node's controller

Scenario status.

Number of users currently running in the node

Time to wait in between spawning new users

Types

amoc_status/0

-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

handle_call_res/0

-type handle_call_res() :: ok | {ok, term()} | {error, term()}.

last_user_id/0

-type last_user_id() :: non_neg_integer().

Highest user id registered in the node

running_status/0

-type running_status() ::
          #{scenario := amoc:scenario(),
            currently_running_users := user_count(),
            highest_user_id := last_user_id()}.

Details about the scenario currently running

state/0

-type state() ::
          #state{scenario :: amoc:scenario() | undefined,
                 status :: status(),
                 last_user_id :: last_user_id(),
                 scenario_state :: amoc_scenario:state()}.

Internal state of the node's controller

status/0

-type status() :: idle | running | terminating | finished | {error, any()} | disabled.

Scenario status.

user_count/0

-type user_count() :: non_neg_integer().

Number of users currently running in the node

user_rate/0

-type user_rate() :: amoc_throttle:rate().

Time to wait in between spawning new users

Functions

add_users(StartId, EndId)

-spec add_users(amoc_scenario:user_id(), amoc_scenario:user_id()) -> ok | {error, term()}.

disable()

-spec disable() -> ok | {error, term()}.

get_status()

-spec get_status() -> amoc_status().

remove_users(Count, ForceRemove)

-spec remove_users(user_count(), boolean()) -> {ok, user_count()}.

start_scenario(Scenario, Settings)

-spec start_scenario(amoc:scenario(), amoc_config:settings()) -> ok | {error, term()}.

stop_scenario()

-spec stop_scenario() -> ok | {error, term()}.

update_settings(Settings)

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

wait_user_rate()

-spec wait_user_rate() -> boolean().