Derive behaviour (derive v0.5.4)

Copy Markdown View Source

@todo add documentation

Summary

Types

@todo add documentation

@todo add documentation

@todo add documentation

@todo add documentation

@todo add documentation

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

@todo add documentation

t()

@todo add documentation

Callbacks

@todo add documentation

@todo add documentation

@todo add documentation

@todo add documentation

@todo add documentation

@todo add documentation

Functions

@todo add documentation

Returns a specification to start this module under a supervisor.

Types

event()

(since 0.1.0)
@type event() :: %{:id => pos_integer(), optional(atom()) => any()}

@todo add documentation

position()

(since 0.1.0)
@type position() :: non_neg_integer()

@todo add documentation

reason()

(since 0.1.0)
@type reason() :: binary() | Exception.t() | term()

@todo add documentation

record()

(since 0.1.0)
@type record() :: Ecto.Schema.schema()

@todo add documentation

repo()

(since 0.1.0)
@type repo() :: Ecto.Repo.t()

@todo add documentation

side_effect()

(since 0.1.0)
@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()

(since 0.1.0)
@type state() :: t()

@todo add documentation

t()

(since 0.1.0)
@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

Callbacks

before_persist(list)

(since 0.1.0)
@callback before_persist([side_effect(), ...]) :: [side_effect(), ...]

@todo add documentation

fetch(repo, list)

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

@todo add documentation

handle_event(event)

(since 0.1.0)
@callback handle_event(event()) :: [side_effect()] | :skip

@todo add documentation

on_failed(repo, reason)

(since 0.1.0)
@callback on_failed(repo(), reason :: term()) :: any() | no_return()

@todo add documentation

on_persisted(repo, list)

(since 0.1.0)
@callback on_persisted(repo(), [event(), ...]) :: any() | no_return()

@todo add documentation

prepare(event)

(since 0.1.0)
@callback prepare(event()) :: event() | :skip

@todo add documentation

Functions

__using__(opts)

(since 0.1.0) (macro)

@todo add documentation

child_spec(init_arg)

(since 0.1.0)

Returns a specification to start this module under a supervisor.

See Supervisor.