# `Mediate.Config`
[🔗](https://github.com/mrmeku/mediate/blob/v0.1.0/lib/mediate/config.ex#L1)

The only runtime configuration the library reads. `boot!/1` validates it
once at boot from a `NimbleOptions` schema and stores it. The adapter is
a module or a `{module, keyword}` pair, and a bare module means `[]`,
which the adapter's `options_schema/0` still validates. The port and the
seam call `resolve/0`. It answers the boot struct under the overrides
`Mediate.Test.with_config/1` put in the process dictionary. It takes the
first non-empty override, from the caller and then from each process in
its `$callers` chain, and merges it over the boot struct field by field.

Fields: * `:adapter` - Required. The module implementing `Mediate.Adapter`, bare or with its options.

* `:clock` (function of arity 0) - A zero-arity function that answers the current time in UTC. `&DateTime.utc_now/0` when absent.

* `:caps` (`t:keyword/0`) - The caps on what a record carries by value. The default value is `[policy_content_bytes: 65536]`.

  * `:policy_content_bytes` (`t:pos_integer/0`) - Policy text kept by value. The default value is `65536`.

# `adapter`

```elixir
@type adapter() :: module() | {module(), keyword()}
```

The adapter module, with its own options beside it when it takes any.

# `caps`

```elixir
@type caps() :: [{:policy_content_bytes, pos_integer()}]
```

The size above which a policy version carries a pointer rather than the text.

# `clock`

```elixir
@type clock() :: (-&gt; DateTime.t())
```

What the port calls for `now`. A test gives one that does not move.

# `t`

```elixir
@type t() :: %Mediate.Config{adapter: adapter(), caps: caps(), clock: clock()}
```

The validated configuration, read once at boot.

# `adapter`

```elixir
@spec adapter(t()) :: {module(), keyword()}
```

The adapter module and its options.

# `boot!`

```elixir
@spec boot!(keyword()) :: t()
```

Validate once at boot and keep the struct for `resolve/0`.

# `new`

```elixir
@spec new(keyword()) :: {:ok, t()} | {:error, Mediate.Error.t()}
```

Validate a keyword list into the struct.

# `new!`

```elixir
@spec new!(keyword()) :: t()
```

`new/1`, and it raises the error.

# `resolve`

```elixir
@spec resolve() :: {:ok, t()} | {:error, Mediate.Error.t()}
```

The boot struct under this process's overrides, or an error when neither exists.

# `to_keyword`

```elixir
@spec to_keyword(t()) :: keyword()
```

The struct as the keyword list `new/1` accepts.

---

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