# `Rho.Dyn.Registry`
[🔗](https://github.com/GenericJam/rho/blob/v0.1.0/lib/rho/dyn/registry.ex#L1)

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 `c: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.

# `key`

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

# `all`

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

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

# `config`

```elixir
@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`

```elixir
@spec entries(atom()) :: %{required(key()) =&gt; module()}
```

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

# `generation`

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

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

# `lookup`

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

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

# `mode`

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

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

# `rebuilding`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
