# `Derive`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L1)

@todo add documentation

# `event`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L23)
*since 0.1.0* 

```elixir
@type event() :: %{:id =&gt; pos_integer(), optional(atom()) =&gt; any()}
```

@todo add documentation

# `position`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L33)
*since 0.1.0* 

```elixir
@type position() :: non_neg_integer()
```

@todo add documentation

# `reason`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L40)
*since 0.1.0* 

```elixir
@type reason() :: binary() | Exception.t() | term()
```

@todo add documentation

# `record`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L47)
*since 0.1.0* 

```elixir
@type record() :: Ecto.Schema.schema()
```

@todo add documentation

# `repo`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L54)
*since 0.1.0* 

```elixir
@type repo() :: Ecto.Repo.t()
```

@todo add documentation

# `side_effect`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L65)
*since 0.1.0* 

```elixir
@type side_effect() :: Derive.SideEffect.t()
```

@todo add documentation, make sure to include the points below

Key points:
* a side effect can be any struct that implements the
  Derive.SideEffect protocol

# `state`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L87)
*since 0.1.0* 

```elixir
@type state() :: t()
```

@todo add documentation

# `t`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L72)
*since 0.1.0* 

```elixir
@type t() :: %Derive{
  batch_size: pos_integer(),
  consumer: module(),
  cursor: %Derive.Cursor{
    __meta__: term(),
    consumer_id: term(),
    last_synced_at: term(),
    position: term(),
    stuck_reason: term(),
    stuck_since: term()
  },
  error_count: non_neg_integer(),
  filters: [{atom(), term()}, ...],
  repo: Ecto.Repo.t(),
  timer: reference() | nil
}
```

@todo add documentation

# `before_persist`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L117)
*since 0.1.0* 

```elixir
@callback before_persist([side_effect(), ...]) :: [side_effect(), ...]
```

@todo add documentation

# `fetch`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L94)
*since 0.1.0* 

```elixir
@callback fetch(repo(), [filter | option, ...]) :: [event()]
when filter: {atom(), term()},
     option: {:after, position()} | {:take, pos_integer()}
```

@todo add documentation

# `handle_event`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L110)
*since 0.1.0* 

```elixir
@callback handle_event(event()) :: [side_effect()] | :skip
```

@todo add documentation

# `on_failed`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L131)
*since 0.1.0* 

```elixir
@callback on_failed(repo(), reason :: term()) :: any() | no_return()
```

@todo add documentation

# `on_persisted`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L124)
*since 0.1.0* 

```elixir
@callback on_persisted(repo(), [event(), ...]) :: any() | no_return()
```

@todo add documentation

# `prepare`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L103)
*since 0.1.0* 

```elixir
@callback prepare(event()) :: event() | :skip
```

@todo add documentation

# `__using__`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L150)
*since 0.1.0* *macro* 

@todo add documentation

# `child_spec`
[🔗](https://github.com/rwillians/derive/blob/v0.5.4/lib/derive.ex#L7)
*since 0.1.0* 

Returns a specification to start this module under a supervisor.

See `Supervisor`.

---

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