Framework.Sequencer.Consumer behaviour (Framework v0.5.0)

View Source

Consumer behavior for cursor persistence and resume.

Implements the binding behavior per sequencer-emitter-spec.md.

Summary

Callbacks

Behavior callback for handling events.

Functions

Get cursor for a named consumer.

Persist cursor for a named consumer.

Resume consumption from stored cursor.

Callbacks

handle_events(events, state)

@callback handle_events(events :: [map()], state :: term()) ::
  {:ok, new_state :: term()} | {:error, reason :: term()}

Behavior callback for handling events.

All consumers must implement this callback.

Functions

get_cursor(consumer_name)

Get cursor for a named consumer.

Returns the last processed sequence or 0 if no cursor exists.

persist_cursor(consumer_name, sequence)

Persist cursor for a named consumer.

Uses the canonical consumer_cursors table per sequencer-emitter-spec.md.

resume_from_cursor(consumer_name)

Resume consumption from stored cursor.

Implements the canonical resume behavior: > last_processed_sequence