Extreme.ListenerWithBackPressure behaviour (extreme v1.1.2)

View Source

The same as Extreme.Listener but uses event_producer functionality which applies backpressure on live events as well.

The way it works is that there's intermediate process which turns off subscription when max_buffer is reached and creates new subscription when all buffered events are processed.

Summary

Callbacks

get_last_event(stream_name, client_state)

@callback get_last_event(stream_name :: String.t(), client_state :: any()) ::
  last_event :: integer()

on_caught_up(client_state)

@callback on_caught_up(client_state :: any()) :: any()

on_init(opts_from_start_link)

@callback on_init(opts_from_start_link :: Keyword.t()) :: {:ok, client_state :: any()}

process_push(push_from_es, stream_name, client_state)

@callback process_push(
  push_from_es :: Extreme.Messages.ResolvedEvent.t(),
  stream_name :: String.t(),
  client_state :: any()
) :: {:ok, event_number :: non_neg_integer()} | :ok | :stop