# `Countersign.Workers.Daily`
[🔗](https://github.com/mkreyman/countersign/blob/v0.1.0/lib/countersign/workers/daily.ex#L1)

The Oban worker that runs the daily sweep (`Countersign.Sweep`): expiry,
then one reminder for each request due one.

    defmodule MyApp.Signing.DailyWorker do
      use Countersign.Workers.Daily, delivery: MyApp.Signing.DeliveryWorker

      @impl Countersign.Workers.Daily
      def config, do: MyApp.Signing.config()
    end

Schedule it with Oban's cron plugin. A job is unique for 23 hours, so a
second insert the same day is dropped. The sweep's clock is the job's
`"now"` arg (ISO 8601) when it has one, else `c:Countersign.Host.now/0`.

A reminder is a delivery job built by the `:delivery` worker's `job/2`
with `reminder: true`, inserted in the same transaction that marks the
request reminded (`:oban`, the Oban instance, default `Oban`). Override
`enqueue_reminder/1` to enqueue it another way.

# `config`

```elixir
@callback config() :: Countersign.Config.t()
```

The config the sweep runs with.

# `enqueue_reminder`

```elixir
@callback enqueue_reminder(Countersign.Request.t()) :: :ok
```

Enqueues the reminder delivery for a request just marked reminded; answers `:ok`.

# `run`

```elixir
@spec run(Countersign.Config.t(), (Countersign.Request.t() -&gt; :ok), map()) ::
  {:ok, %{reminded: non_neg_integer(), expired: non_neg_integer()}}
```

Runs the sweep with `config`: expiry first, so a reminder whose enqueue
fails can never hold back a link's end, then reminders through `enqueue`.
Answers how many requests it reminded and expired.

---

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