ExDaytona.Transport.HTTPStream behaviour (ex_daytona v0.2.0)

Copy Markdown View Source

Behaviour for streaming HTTP transports (both directions).

stream/7 issues a request and folds over response events — {:status, integer}, {:headers, [{name, value}]}, and {:data, binary} — with the reducer able to halt consumption early. The request body may itself be a lazy {:stream, Enumerable.t()} for constant-memory uploads.

Summary

Callbacks

Options: :receive_timeout (idle timeout between response events, ms), :pool (implementation-specific pool selector).

Types

body()

@type body() :: iodata() | {:stream, Enumerable.t()} | nil

event()

@type event() ::
  {:status, non_neg_integer()}
  | {:headers, [{binary(), binary()}]}
  | {:data, binary()}

Callbacks

stream(method, url, headers, body, acc, function, opts)

@callback stream(
  method :: String.t(),
  url :: String.t(),
  headers :: [{binary(), binary()}],
  body :: body(),
  acc,
  (event(), acc -> {:cont, acc} | {:halt, acc}),
  opts :: keyword()
) :: {:ok, acc} | {:error, term(), acc}
when acc: term()

Options: :receive_timeout (idle timeout between response events, ms), :pool (implementation-specific pool selector).

Returns {:ok, acc} when the response completed or the reducer halted, {:error, reason, acc} on transport failure.