View Source RabbitMQStream.Consumer.OffsetTracking behaviour (rabbitmq_stream v0.4.1)

Behavior for offset tracking strategies. If you pass multiple strategies to the consumer, which will be executed in order, and and halt after the first one that returns a :store request.

Existing Strategies

You can use the default strategies by passing a shorthand alias:

Summary

Callbacks

Optional Callback executed after every chunk, which can be used to update the state.

Initializes the strategy state.

Callback responsible for deciding whether to store the offset, based on its internal state.

Types

Callbacks

Link to this callback

after_chunk(state, chunk, subscription)

View Source (optional)
@callback after_chunk(
  state :: term(),
  chunk :: RabbitMQStream.OsirisChunk.t(),
  subscription :: RabbitMQStream.Consumer.t()
) :: term()

Optional Callback executed after every chunk, which can be used to update the state.

Useful, for example, to store the offset after a certain number of messages.

@callback init(opts :: term()) :: term()

Initializes the strategy state.

Parameters

  • opts - a keyword list of the options passed to the consumer, merged with the options passed to the strategy itself.
Link to this callback

run(state, subscription)

View Source
@callback run(state :: term(), subscription :: RabbitMQStream.Consumer.t()) ::
  {:store, state :: term()} | {:skip, state :: term()}

Callback responsible for deciding whether to store the offset, based on its internal state.

Parameters

  • state - the state of the strategy
  • subscription - the state of the owner subscription process