View Source Buckaroo.EventSource behaviour (buckaroo v0.4.2)

A simple SSE implementation.

Link to this section Summary

Types

SSE event.

SSE callback result.

Callbacks

Incoming process messages.

Initialize the SSE.

Link to this section Types

@type event() ::
  %{
    :data => binary(),
    optional(:id) => binary(),
    optional(:type) => binary(),
    optional(:retry) => pos_integer()
  }
  | binary()

SSE event.

@type result(state) ::
  {:ok, state}
  | {:ok, state, :hibernate}
  | {:reply, event() | [event()], state}
  | {:reply, event() | [event()], state, :hibernate}
  | {:stop, state}

SSE callback result.

Link to this section Callbacks

@callback info(any(), state) :: result(state) when state: any()

Incoming process messages.

@callback init(conn :: Plug.Conn.t(), state :: state) :: result(state) when state: any()

Initialize the SSE.

Passes the connection and the given state.

Link to this callback

terminate(reason, req, state)

View Source
@callback terminate(reason :: any(), req :: map(), state) :: :ok when state: any()

SSE termination.