GenDurable.Registry (gen_durable v0.2.0)

Copy Markdown View Source

Resolves {fsm_name, fsm_version} to an FSM module.

Per-instance, not global: the engine supervisor owns a protected ETS table (new/1 at boot) whose tid travels in the engine config, so separate engine instances hold separate registries and there is no registry process at all.

Two resolution paths:

  • Explicit registry — modules passed in :fsms are indexed by __gd_name__/0 + __gd_version__/0 in the table. Use this when a machine has a custom :name (the fsm column is then not a module name) or to keep old :versions running: old instances finish on their fsm_version, so the old module must stay registered.
  • Dynamic fallback — on a miss, the fsm name is interpreted as a module name (its default is inspect(module)) and accepted if that module is a GenDurable.FSM whose own name and version match the row. So a machine with the default name and a single version needs no :fsms entry at all.

Reads are an ETS lookup plus, only on a miss, a cheap module check — no process call on the hot path.

Summary

Functions

Look up the module for {name, version} in table — the explicit registry first, then a dynamic resolution of name as a module. Raises NotFound if neither matches.

Create and seed the registry table from the :fsms modules. Owned by the calling process (the engine supervisor), so it lives and dies with the instance. Returns the table tid, carried in the engine config.

Functions

fetch!(table, name, version)

Look up the module for {name, version} in table — the explicit registry first, then a dynamic resolution of name as a module. Raises NotFound if neither matches.

new(fsms)

Create and seed the registry table from the :fsms modules. Owned by the calling process (the engine supervisor), so it lives and dies with the instance. Returns the table tid, carried in the engine config.