Pristine.Ports.Transport behaviour (Pristine v0.4.0)

Copy Markdown View Source

Transport boundary for sending requests.

send/2 remains the only required callback. Existing adapters that implement only send/2 continue to support ordinary request execution.

Adapters may additionally advertise provider-neutral runtime capabilities with capabilities/1 and implement send_cancelable/3. Capability advertisement must be side-effect free. Absence or malformed advertisement is unverified, never implicit support.

Implementing send_cancelable/3 alone is not proof of physical cancellation; an adapter must only advertise cancellation capabilities that its owner has verified through the underlying transport stack.

Summary

Callbacks

capabilities(t)

(optional)
@callback capabilities(Pristine.Core.Context.t()) :: map()

send(t, t)

@callback send(Pristine.Core.Request.t(), Pristine.Core.Context.t()) ::
  {:ok, Pristine.Core.Response.t()} | {:error, term()}

send_cancelable(t, t, t)

(optional)
@callback send_cancelable(
  Pristine.Core.Request.t(),
  Pristine.Core.Context.t(),
  Pristine.Cancellation.t()
) ::
  {:ok, Pristine.Core.Response.t()} | {:error, term()}