buckaroo v0.3.0 Buckaroo.EventSource behaviour 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

Link to this type

event()

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

SSE event.

Link to this type

result(state)

View Source
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

Link to this callback

info(any, state)

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

Incoming process messages.

Link to this callback

init(conn, state)

View Source
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
terminate(reason :: any(), req :: map(), state) :: :ok when state: any()

SSE termination.