# `Trellis.SelfCheckJob`
[🔗](https://github.com/salesforce-misc/trellis/blob/v0.1.0-alpha/clients/elixir/lib/trellis/self_check.ex#L1)

A background check of a target table, as `Trellis.self_check/3` starts it
and `Trellis.self_check_job/2` reads it back.

- `id` is what `Trellis.self_check_job/2` takes.
- `target` is the audited target's bare table name.
- `mode` is `:standard` or `:strict`, as the job was started. A second
  `Trellis.self_check/3` of a target whose job is still running returns
  that job, so its mode is the first call's.
- `state` is `:queued` (no worker has taken it up yet; with no drain
  worker anywhere in the fleet it stays so), `:running`, then `:done`,
  `:failed` (`error` says why) or `:cancelled` (the worker running it shut
  down; `error` says so). Only `:done` carries a report.
- `rows_compared` counts the distinct keys the pages so far compared; it
  moves while the job is `:running`.
- `report` is the `Trellis.SelfCheckReport`, once the job is `:done`.
- `error` says why a `:failed` or `:cancelled` job ended.

A job ends when its transform is dropped, and `Trellis.self_check_job/2`
then returns `nil` for it.

# `state`

```elixir
@type state() :: :queued | :running | :done | :failed | :cancelled
```

# `t`

```elixir
@type t() :: %Trellis.SelfCheckJob{
  error: String.t() | nil,
  id: integer(),
  mode: :standard | :strict,
  report: Trellis.SelfCheckReport.t() | nil,
  rows_compared: non_neg_integer(),
  state: state(),
  target: String.t()
}
```

# `finished?`

```elixir
@spec finished?(t()) :: boolean()
```

Whether the job has ended, so polling it again changes nothing.

---

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