View Source ActiveMemory.TableHeir (ActiveMemory v0.7.0)
Stable "owner of last resort" for the ETS tables created by ActiveMemory.Store.
Each ETS table is created with this process set as its ETS :heir. When a
store process terminates, ETS transfers the table to this process instead of
destroying it, preserving the data. When the store restarts it reclaims the
table via claim/1, so ETS data survives store crashes and restarts.
This process is started automatically by ActiveMemory.Application; no changes
to a host application's supervision tree and no changes to the Store API are
required. When the heir is not running, stores fall back to the previous
behaviour of creating a fresh table.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Reclaim ownership of table for the calling process.
Return the pid of the running heir, or nil when it is not started.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec claim(atom()) :: :ok | {:error, :not_held}
Reclaim ownership of table for the calling process.
Returns :ok when the heir is currently holding table and has handed it back
to the caller, or {:error, :not_held} when the heir is not the table's owner
(the table does not exist, or it is owned by another process).
iex> ActiveMemory.TableHeir.claim(:a_table_the_heir_does_not_hold)
{:error, :not_held}
@spec whereis() :: pid() | nil
Return the pid of the running heir, or nil when it is not started.