amoc_coordinator (amoc v4.1.0)

View Source

This module allows to synchronize the users and act on groups of them.

Summary

Functions

See also: add/3.

Adds the current process data. Usually called in the start/2 callback of an amoc scenario.

Resets a coordinator, that is, calls all coordination actions with reset as the coordination data.

Starts a coordinator. Usually called in the init callback of an amoc scenario.

Stops a coordinator.

Types

action/0

-type action() ::
          fun((coordination_event(), [data()]) -> any()) |
          fun((coordination_event(), maybe_coordination_data(), maybe_coordination_data()) -> any()) |
          fun((coordination_event()) -> any()).

coordination_actions/0

-type coordination_actions() :: [action()] | action().

coordination_event/0

-type coordination_event() :: {event_type(), non_neg_integer()}.

coordination_item/0

-type coordination_item() :: {num_of_users(), coordination_actions()}.

coordination_timeout_in_sec/0

-type coordination_timeout_in_sec() :: pos_integer() | infinity.

data/0

-type data() :: {pid(), Data :: any()}.

event/0

-type event() :: coordinator_timeout | reset_coordinator | {coordinate, {pid(), term()}}.

event_type/0

-type event_type() :: coordinate | timeout | stop | reset.

maybe_coordination_data/0

-type maybe_coordination_data() :: data() | undefined.

name/0

-type name() :: term().

normalized_coordination_item/0

-type normalized_coordination_item() :: {NoOfUsers :: pos_integer() | all, [action()]}.

num_of_users/0

-type num_of_users() :: pos_integer() | {Min :: pos_integer(), Max :: pos_integer()} | all.

plan/0

-type plan() :: [coordination_item()] | coordination_item().

Functions

add(Name, Data)

-spec add(name(), any()) -> ok.

See also: add/3.

add(Name, Pid, Data)

-spec add(name(), pid(), any()) -> ok.

Adds the current process data. Usually called in the start/2 callback of an amoc scenario.

notify(Name, Event)

-spec notify(name(), coordinator_timeout | reset_coordinator | {coordinate, {pid(), term()}}) -> ok.

reset(Name)

-spec reset(name()) -> ok.

Resets a coordinator, that is, calls all coordination actions with reset as the coordination data.

start(Name, CoordinationPlan)

-spec start(name(), plan()) -> ok | error.

See also: start/3.

start(Name, CoordinationPlan, Timeout)

-spec start(name(), plan(), coordination_timeout_in_sec()) -> ok | error.

Starts a coordinator. Usually called in the init callback of an amoc scenario.

stop(Name)

-spec stop(name()) -> ok.

Stops a coordinator.