Beethoven.RoleServer (Beethoven v0.3.9)

DEPRECATED! Do not use. Use Beethoven.RoleMgmt instead.

This server is responsible for the management and allocation of specialized OTP complaint PIDs. Roles are defined in in the application config for :beethoven.

Example

config :beethoven,
  ...
  roles: [
    # {<AtomName>, <Module>, <Initial Args>, <InstanceCount>}
    {:test, Beethoven.TestRole, [arg1: "arg1"], 1}
  ]

Based on the definition for each role, the nodes in the Beethoven cluster will ensure the required amount of that service is running across the cluster. The number of service instances needed for the role is defined with the InstanceCount element in the tuple. These services are spread across the cluster.

Summary

Types

Role list in the form of a map.

Simplified type for tracker records. Just excludes the table name from the record tuple.

Functions

CoreServer

Tell the local CoreServer that we want to be alerted to changes to cluster node state. Update will be sent in the form of a cast.

Returns a specification to start this module under a supervisor.

Manually copy the tracking DB to the node.

Similar to :mnesia.dirty_select/2 but only needs the match spec as an argument. The table name of the DistrServer Elixir.Beethoven.RoleServer's mnesia table is input automatically as the 1st arity.

Fetches data from the DistrServer Elixir.Beethoven.RoleServer's mnesia table. Uses a record key to query the data. Will return all matching records.

Fetches all records from the DistrServer Elixir.Beethoven.RoleServer's mnesia table.

Retrieves roles from config and converts to map.

Returns the name of the DistrServer Elixir.Beethoven.RoleServer's mnesia table.

Creates a map from a list of maps. First element of the map needs to be an atom. This same atom will be the key for the rest of the data in the map.

Starts assignment job on the RoleServer.

Supervisor Entry point.

Subscribes to the table mapped to the DistrServer Elixir.Beethoven.RoleServer's mnesia table.

Checks if the DistrServer Elixir.Beethoven.RoleServer's mnesia table exists.

Holds the thread until the DistrServer Elixir.Beethoven.RoleServer's mnesia table becomes available, or timeout occurs. Defaults to 1_000 milliseconds for timeouts and 15 milliseconds for checking intervals.

Types

roleMap()

@type roleMap() :: map()

Role list in the form of a map.

roleRecord()

@type roleRecord() ::
  {roleName :: atom(), roleModule :: module(), args :: any(),
   instances :: integer()}

Simplified type for tracker records. Just excludes the table name from the record tuple.

Functions

alert_me()

@spec alert_me() :: :ok

CoreServer

Tell the local CoreServer that we want to be alerted to changes to cluster node state. Update will be sent in the form of a cast.

Example

{:node_update, {nodeName, status}}

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

copy_tracker()

@spec copy_tracker() :: :ok | :already_exists | {:error, any()}

Manually copy the tracking DB to the node.

dirty_select(matchSpec)

@spec dirty_select(:ets.match_spec()) :: [tuple()] | list()

Similar to :mnesia.dirty_select/2 but only needs the match spec as an argument. The table name of the DistrServer Elixir.Beethoven.RoleServer's mnesia table is input automatically as the 1st arity.

fetch(key)

@spec fetch(any()) :: [tuple()] | list()

Fetches data from the DistrServer Elixir.Beethoven.RoleServer's mnesia table. Uses a record key to query the data. Will return all matching records.

fetch_all()

@spec fetch_all() :: [tuple()] | list()

Fetches all records from the DistrServer Elixir.Beethoven.RoleServer's mnesia table.

get_role_config()

@spec get_role_config() :: roleMap()

Retrieves roles from config and converts to map.

get_table_name()

@spec get_table_name() :: module() | atom()

Returns the name of the DistrServer Elixir.Beethoven.RoleServer's mnesia table.

role_list_to_map(role_list)

@spec role_list_to_map([roleRecord()]) :: roleMap()

Creates a map from a list of maps. First element of the map needs to be an atom. This same atom will be the key for the rest of the data in the map.

start_assign()

@spec start_assign() :: :ok

Starts assignment job on the RoleServer.

start_link(init_args \\ [])

@spec start_link(any()) :: GenServer.on_start()

Supervisor Entry point.

subscribe(type \\ :simple)

@spec subscribe(:simple | :detailed) :: :ok

Subscribes to the table mapped to the DistrServer Elixir.Beethoven.RoleServer's mnesia table.

Matches based on subscription

:simple

{:mnesia_table_event, {:atom, record(), _op_data}}

:detailed

{:mnesia_table_event, {:atom, module() | :atom(), record(), [] | [record()], _op_data}}

table_exists?()

@spec table_exists?() :: boolean()

Checks if the DistrServer Elixir.Beethoven.RoleServer's mnesia table exists.

until_exists(int \\ 15, timeout \\ 1000, acc \\ 0)

Holds the thread until the DistrServer Elixir.Beethoven.RoleServer's mnesia table becomes available, or timeout occurs. Defaults to 1_000 milliseconds for timeouts and 15 milliseconds for checking intervals.