K8s.Client.Mint.Request (k8s v2.7.0)

View Source

Maintains the state of a HTTP or Websocket request.

Summary

Types

Describes the mode the request is currently in.

t()

Defines the state of the request.

Types

request_modes()

@type request_modes() :: :pending | :receiving | :closing | :terminating

Describes the mode the request is currently in.

  • ::pending - The request is still streaming its body to the server
  • :receiving - The request is currently receiving response parts / frames
  • :closing - Websocket requests only: The :close frame was received but the process wasn't terminated yet
  • :terminating - HTTP requests only: The :done part was received but the request isn't cleaned up yet

t()

@type t() :: %K8s.Client.Mint.Request{
  buffer: list(),
  caller_ref: reference(),
  mode: request_modes(),
  pending_request_body: binary(),
  pool: pid() | nil,
  request_ref: Mint.Types.request_ref(),
  stream_to: pid() | {pid(), reference()} | nil,
  websocket: Mint.WebSocket.t() | nil
}

Defines the state of the request.

  • :request_ref - Mint request reference
  • :caller_ref - Monitor reference of the calling process.
  • :stream_to - the process expecting response parts sent to.
  • :pool - the PID of the pool so we can checkin after the last part is sent.
  • :websocket - for WebSocket requests: The websocket state (Mint.WebSocket.t()).
  • :mode - defines what mode the request is currently in.
  • :buffer - Holds the buffered response parts or frames that haven't been sent to / received by the caller yet
  • :pending_request_body - Part of the request body that has not been sent yet.

Functions

map_frame(arg)

@spec map_frame({:binary, binary()} | {:close, any(), any()}) ::
  {:close, {integer(), binary()}}
  | {:error, binary()}
  | {:stderr, binary()}
  | {:stdout, binary()}

map_outgoing_frame(data)

@spec map_outgoing_frame(
  {:stdin, binary()}
  | {:close, integer(), binary()}
  | :close
  | :exit
) ::
  {:ok, :close | {:text, binary()} | {:close, integer(), binary()}}
  | K8s.Client.HTTPError.t()

map_response(arg)

@spec map_response({:done, reference()} | {atom(), reference(), any()}) ::
  {:done | {atom(), any()}, reference()}

maybe_terminate_request(request)

@spec maybe_terminate_request(t()) :: {t(), t()} | :pop

new(fields)

@spec new(keyword()) :: t()

put_response(request, response)

@spec put_response(t(), :done | {atom(), any()}) :: :pop | {t(), t()}

receive_upgrade_response(conn, ref)

@spec receive_upgrade_response(Mint.HTTP.t(), reference()) ::
  {:ok, Mint.HTTP.t(), map()} | {:error, Mint.HTTP.t(), Mint.Types.error()}

recv(request, from)

@spec recv(t(), GenServer.from()) :: :pop | {t(), t()}

stream_request_body(req, conn)

@spec stream_request_body(t(), Mint.HTTP.t()) ::
  {:ok, t(), Mint.HTTP.t()} | {:error, Mint.HTTP.t(), Mint.Types.error()}