Beethoven.DistrServer behaviour (Beethoven v0.3.7)

A modified version of the built-in GenServer. Specialized for Beethoven's No-Master design; this GenServer will initialize a Mnesia table on creation. These tables act as the primary state for the distributed process. Supports most GenServer logic and callbacks.

Summary

Types

Copy options for the Mnesia table.

Configuration for the DistrServer instance.

Callbacks

-Callback required-

-Callback required-

-Callback required-

Functions

Sends a cast to the provided DistrServer. Similar to GenServer.call/2 and GenServer.call/3

Sends a cast to the provided DistrServer. Similar to GenServer.cast/2

Converts the DistrConfig() into the tableConfig() type.

Starts a DistrServer process under the supervisor tree. Similar to GenServer.start_link/2 and GenServer.start_link/3

Types

copyTypes()

@type copyTypes() :: :local | :multi

Copy options for the Mnesia table.

  • :local -> Copies are only on the table-creating-node.
  • :multi -> Copies are pushed to ALL nodes in the cluster.

distrConfig()

@type distrConfig() :: %{
  tableName: atom(),
  columns: [atom()],
  indexes: [atom()],
  dataType: atom(),
  copyType: copyTypes()
}

Configuration for the DistrServer instance.

  • :tableName -> Atomic name for the table.
  • :columns -> List of atoms representing the names of columns in the name.
  • :indexes -> List of table columns that should be indexed. Note: Indexing a column will slow writes to it, but make read operations consistent regardless of the table's size.
  • :dataType -> Data type for the Mnesia table.
  • :copyType -> How the new table will be copied across the Beethoven cluster.

Callbacks

config()

@callback config() :: distrConfig()

-Callback required-

DistrServer configuration. See distrConfig() type for more information on the return.

create_action(tableConfig)

@callback create_action(tableConfig :: Beethoven.MnesiaTools.tableConfig()) :: :ok

-Callback required-

Callback that is triggered when the process creates the Mnesia Table for the cluster.

entry_point(var)

@callback entry_point(var :: any()) :: {:ok, var :: any()}

-Callback required-

Entry point for the DistrServer process. Similar to init/1 for GenServers.

Functions

call(server, request, timeout \\ 5000)

@spec call(GenServer.server(), any(), timeout()) :: any()

Sends a cast to the provided DistrServer. Similar to GenServer.call/2 and GenServer.call/3

cast(server, request)

@spec cast(GenServer.server(), any()) :: :ok

Sends a cast to the provided DistrServer. Similar to GenServer.cast/2

distr_to_table_conf(distrConfig)

@spec distr_to_table_conf(distrConfig()) :: Beethoven.MnesiaTools.tableConfig()

Converts the DistrConfig() into the tableConfig() type.

start_link(module, init_args, options \\ [])

@spec start_link(module(), any(), GenServer.options()) :: GenServer.on_start()

Starts a DistrServer process under the supervisor tree. Similar to GenServer.start_link/2 and GenServer.start_link/3