# `Tank.Store`
[🔗](https://github.com/oshlabs/tank/blob/v0.2.0/lib/tank/store.ex#L1)

The desired-state store seam: Tank's view of the `[:tank, :pods, …]` subtree
of a Khepri store.

## Bring-your-own-or-default

Tank is a library, so it never owns a store's cluster lifecycle. Which side
starts Khepri is chosen by the `:data_dir` option:

  * `:data_dir` set — Tank **boots a default store** at that directory and owns
    it (standalone, dev, tests).
  * `:data_dir` `nil` — the store named by `:store_id` is assumed to be started
    by the consumer; Tank only attaches its projection.

Either way Tank registers a `khepri_projection` mirroring `[:tank, :pods, **]`
into the ETS table `:tank_pods`, so `list_pods/0` is a fast local
read (the substrate the reconciler will watch). Single-pod reads go straight
to Khepri so they are authoritative.

Pods are stored as `%Tank.Pod{}` structs at `[:tank, :pods, name]`.

# `child_spec`

Supervisor child spec for the store seam.

# `create_pod`

```elixir
@spec create_pod(Tank.Pod.t()) :: :ok | {:error, :exists | term()}
```

Write a pod only if it does not already exist (the create-if-absent seed
path). Returns `{:error, :exists}` if a pod with that name is already stored.

# `delete_pod`

```elixir
@spec delete_pod(String.t()) :: :ok | {:error, term()}
```

Delete a pod by name. Deleting a missing pod is a no-op `:ok`.

# `get_pod`

```elixir
@spec get_pod(String.t()) :: {:ok, Tank.Pod.t()} | {:error, :not_found}
```

Fetch a single pod by name (authoritative read straight from Khepri).

# `list_pods`

```elixir
@spec list_pods() :: [Tank.Pod.t()]
```

List all stored pods via the ETS projection — a fast local read. Eventually
consistent with writes (the reconciler is level-triggered, so that is fine).

# `put_pod`

```elixir
@spec put_pod(Tank.Pod.t()) :: :ok | {:error, term()}
```

Write (create or overwrite) the desired state of a pod.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Start the store seam. See the moduledoc for `:store_id` / `:data_dir`.

---

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