amoc_controller (amoc v4.1.0)
View SourceMain 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
-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 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, status :: status(), last_user_id :: last_user_id(), scenario_state :: amoc_scenario:state()}.
Internal state of the node's controller
-type status() :: idle | running | terminating | finished | {error, any()} | disabled.
Scenario status.
-type user_count() :: non_neg_integer().
Number of users currently running in the node
-type user_rate() :: amoc_throttle:rate().
Time to wait in between spawning new users
Functions
-spec add_users(amoc_scenario:user_id(), amoc_scenario:user_id()) -> ok | {error, term()}.
-spec disable() -> ok | {error, term()}.
-spec get_status() -> amoc_status().
-spec remove_users(user_count(), boolean()) -> {ok, user_count()}.
-spec start_scenario(amoc:scenario(), amoc_config:settings()) -> ok | {error, term()}.
-spec stop_scenario() -> ok | {error, term()}.
-spec update_settings(amoc_config:settings()) -> ok | {error, term()}.
-spec wait_user_rate() -> boolean().