Beethoven.MnesiaTools (Beethoven v0.3.7)

Generic Library to simplify certain Mnesia tasks.

Summary

Types

TableConfig contains the payload needed to create the state table needed by the process.

Functions

Copies a replica of a desired table to local node memory.

Creates table if it does not already exist. Applies indexes on creation. Will

Removes the replica of a desired table from local memory.

Subscribe to changes to a Mnesia table.

Runs a job within a synchronous transaction

Check if a Mnesia table exists in the cluster.

Types

tableConfig()

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

TableConfig contains the payload needed to create the state table needed by the process.

Functions

copy_table(table)

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

Copies a replica of a desired table to local node memory.

The table may already exist in memory for the following reasons:

  • The table was created for all nodes, and this node was already in the cluster.
  • The table was initialized on this node.
  • A node with the same name was successfully joined the cluster in the past, and power-cycled.

create_table_ifnot_exist(tableConfig)

@spec create_table_ifnot_exist(tableConfig()) :: :ok | :already_exists

Creates table if it does not already exist. Applies indexes on creation. Will

delete_copy(table)

@spec delete_copy(atom()) :: :ok

Removes the replica of a desired table from local memory.

subscribe(tableName)

@spec subscribe(atom()) :: {:ok, node()} | {:error, reason :: term()}

Subscribe to changes to a Mnesia table.

sync_run(fun)

@spec sync_run((-> any())) :: any() | {:error, any()}

Runs a job within a synchronous transaction

table_exists?(table)

@spec table_exists?(atom()) :: boolean()

Check if a Mnesia table exists in the cluster.