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

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

Specs

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

SSE event.

Specs

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

Specs

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

Incoming process messages.

Specs

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

Specs

terminate(reason :: any(), req :: map(), state) :: :ok when state: any()

SSE termination.