# `Lotus.Source.Registry`
[🔗](https://github.com/elixir-lotus/lotus/blob/v1.2.0/lib/lotus/source/registry.ex#L1)

Names the processes an adapter starts for a source, without minting atoms.

Sources created in a UI carry arbitrary string names, and a registered
process normally needs an atom. This `Registry` has unique keys, so a
per-source process is reached through a via tuple whose key is a term:

    name = Lotus.Source.Registry.via(MyApp.Adapters.HTTP, "warehouse")
    {MyApp.Pool, name: name}

`Lotus.Source.Supervisor` starts the registry. An adapter names the
children it returns from `c:Lotus.Source.Adapter.source_children/2`
through `via/2` and reaches them later with `whereis/2`. Adapters that run
more than one process per source tag them with `via/3`.

# `key`

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

# `via`

```elixir
@spec via(module(), String.t()) :: {:via, Registry, {module(), key()}}
```

Returns the via tuple for the process an adapter runs for `name`.

# `via`

```elixir
@spec via(module(), String.t(), term()) :: {:via, Registry, {module(), key()}}
```

Returns the via tuple for one of several processes an adapter runs for
`name`, told apart by `tag`.

# `whereis`

```elixir
@spec whereis(module(), String.t()) :: pid() | nil
```

Returns the pid registered through `via/2`, or `nil` when the process is
not running.

`Registry` removes a key a moment after its owner exits, so a lookup right
after a stop can still hold the dead pid. This function checks the pid is
alive and returns `nil` otherwise.

# `whereis`

```elixir
@spec whereis(module(), String.t(), term()) :: pid() | nil
```

Returns the pid registered through `via/3`, or `nil` when the process is
not running.

---

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