Terminus v0.0.2 Terminus.Request View Source

A GenStage producer module for creating streaming HTTP requests.

Each request is a GenStage process, enabling creating powerful concurrent data flows.

Usage

# Create the connection process
iex> Terminus.Request.connect(:https, host, 443)
{:ok, pid}

# Begin a request
iex> Terminus.Request.request(pid, "GET", path, headers, body)
:ok

# Stream the result
iex> GenStage.stream([{pid, cancel: :transient}])
%Stream{}

Link to this section Summary

Types

t()

Streaming HTTP request state

Functions

Creates a new connection to a given server and returns a GenStage pid.

Sends a request to the connected server.

Link to this section Types

Link to this type

t()

View Source
t() :: %Terminus.Request{
  chunker: atom(),
  conn: map(),
  demand: integer(),
  events: list(),
  last_resp: atom(),
  ref: String.t(),
  response: Terminus.Response.t()
}

Streaming HTTP request state

Link to this section Functions

Link to this function

connect(scheme, host, port, opts \\ [])

View Source
connect(atom(), String.t(), integer(), keyword()) ::
  {:ok, pid()} | {:error, String.t()}

Creates a new connection to a given server and returns a GenStage pid.

Link to this function

request(pid, method, path, headers, body, chunker \\ :raw)

View Source
request(pid(), String.t(), String.t(), list(), String.t() | nil, atom()) :: :ok

Sends a request to the connected server.

The function is asynchronous and returns :ok. The GenStage pid can be subscribed to to listen to streaming data chunks.