Mojentic.Realtime.Transport behaviour (Mojentic v1.5.0)

Copy Markdown View Source

Transport behaviour for the realtime subsystem.

The gateway owns I/O against this contract so unit tests can replace the live WebSocket with a scripted, deterministic transport. Production implementation: Mojentic.Realtime.MintTransport.

Summary

Callbacks

close(pid)

@callback close(pid()) :: :ok

connect(url, headers, opts)

@callback connect(
  url :: String.t(),
  headers :: [{String.t(), String.t()}],
  opts :: keyword()
) ::
  {:ok, pid()} | {:error, term()}

send(pid, payload)

@callback send(pid(), payload :: map()) :: :ok | {:error, term()}

subscribe(pid, subscriber)

@callback subscribe(pid(), subscriber :: pid()) :: :ok