Rho.Dyn.Registry (rho v0.1.0)

Copy Markdown View Source

Reads the Dyn registry: one ETS table owned (and only written) by Rho.Dyn.Keeper, named like the Keeper. It maps logical names to the current generation's modules:

  • {:tool, "weather"} (a tool's Rho.Tool.name/0),
  • {:screen, "Notes"} (the module name below Dyn.),
  • {:module, "Helpers"} (anything else).

The whole mapping is one row, {:generation, n, entries}, so a switch of generations is a single insert: a reader sees the old set or the new one, never a mix. Other rows: {:mode, :booting | :normal | :safe}, {:rebuilding, n} while the launch rebuilds generation n for a new Core in the background (its entries are empty until it loads), and {:config, map} (the Keeper's data dir and options, for Rho.Dyn).

Every read takes the table (the Keeper's name, Rho.Dyn.Keeper for the app's) and answers sensibly while no Keeper runs (no Dyn layer). Rho.Dyn wraps the common reads with the app's Keeper as default.

Summary

Functions

The current generation's {name, module} of kind, sorted by name.

The Keeper's config: :dir (its data dir, Rho.Dyn.Store's root), :keeper, :approval, :build and :rebuild_timeout_ms; {:error, :not_running} without a Keeper.

The current generation's whole mapping, %{key => module} (empty when none).

The current generation's number; 0 when none is loaded.

The current generation's module for key; :error when it has none.

The Keeper's mode: :booting, :normal, :safe (no Dyn code loaded), or :off (no Keeper).

The generation this launch is rebuilding for a new Core, or nil.

Types

key()

@type key() :: {:tool | :screen | :module, String.t()}

Functions

all(kind, table)

@spec all(:tool | :screen | :module, atom()) :: [{String.t(), module()}]

The current generation's {name, module} of kind, sorted by name.

config(table)

@spec config(atom()) :: {:ok, map()} | {:error, :not_running}

The Keeper's config: :dir (its data dir, Rho.Dyn.Store's root), :keeper, :approval, :build and :rebuild_timeout_ms; {:error, :not_running} without a Keeper.

entries(table)

@spec entries(atom()) :: %{required(key()) => module()}

The current generation's whole mapping, %{key => module} (empty when none).

generation(table)

@spec generation(atom()) :: non_neg_integer()

The current generation's number; 0 when none is loaded.

lookup(key, table)

@spec lookup(key(), atom()) :: {:ok, module()} | :error

The current generation's module for key; :error when it has none.

mode(table)

@spec mode(atom()) :: :off | :booting | :normal | :safe

The Keeper's mode: :booting, :normal, :safe (no Dyn code loaded), or :off (no Keeper).

rebuilding(table)

@spec rebuilding(atom()) :: pos_integer() | nil

The generation this launch is rebuilding for a new Core, or nil.