# `Ankusa.SourceStore.Static`
[🔗](https://github.com/jamescarr/ankusa/blob/ankusa-v0.7.0/packages/ankusa/lib/ankusa/source_store.ex#L352)

Default source store: sources are declared in config as a map of
`source_id => keyword/map` (see `Ankusa.Source.new/2`) and cached in
`:persistent_term`. Change rarely, read on every request.

It implements only the read callbacks, so the admin API's write routes answer
`409 source_store_read_only` against it. Use
`Ankusa.SourceStore.Persistent` to manage sources at runtime.

# `publish`

```elixir
@spec publish(atom(), %{required(String.t()) =&gt; keyword() | map() | Ankusa.Source.t()}) ::
  {:ok, [String.t()]}
```

Replace the sources a running instance serves with `sources` (the same
`source_id => keyword/map` shape as the `:sources` option), without a restart.

This is how a config reload rotates a secret: the caller re-reads its config,
resolves its secrets again and publishes the result. Every source is built
and checked with the rules the instance boots under (`wal: :none` durability,
a shared source with no verifier, the verifier's own options, egress), so a
spec that would refuse to boot is refused here and the instance keeps serving
the sources it has. Nothing is applied unless all of them pass.

Reads see the new config on their next `fetch/2`, so a hook already being
verified finishes against the secret it started with. Returns the ids that
were added, removed, or changed, sorted. Raises `ArgumentError` naming the
source when a spec is refused, and `ArgumentError` when the instance does
not run `Ankusa.SourceStore.Static`: a writable store keeps its sources
elsewhere.

# `with_sources`

```elixir
@spec with_sources(Ankusa.Config.t(), %{
  required(String.t()) =&gt; keyword() | map() | Ankusa.Source.t()
}) ::
  {Ankusa.Config.t(), [String.t()]}
```

`config` with `sources` as its static sources, checked with the rules the
instance boots under (see `publish/2`), and the ids that were added, removed or
changed, sorted. Nothing is stored: `Ankusa.Reload` applies the result together
with the other keys a config reload changes. Raises `ArgumentError` naming the
source when a spec is refused.

---

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