View Source K8s.Client.Mint.Request (k8s v2.4.2)

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

@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
@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

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

map_outgoing_frame(data)

View Source
@spec map_outgoing_frame(
  {:stdin, binary()}
  | {:close, integer(), binary()}
  | :close
  | :exit
) ::
  {:ok, :close | {:text, binary()} | {:close, integer(), binary()}}
  | K8s.Client.HTTPError.t()
@spec map_response({:done, reference()} | {atom(), reference(), any()}) ::
  {:done | {atom(), any()}, reference()}
Link to this function

maybe_terminate_request(request)

View Source
@spec maybe_terminate_request(t()) :: {t(), t()} | :pop
@spec new(keyword()) :: t()
Link to this function

put_response(request, response)

View Source
@spec put_response(t(), :done | {atom(), any()}) :: :pop | {t(), t()}
Link to this function

receive_upgrade_response(conn, ref)

View Source
@spec receive_upgrade_response(Mint.HTTP.t(), reference()) ::
  {:ok, Mint.HTTP.t(), map()} | {:error, Mint.HTTP.t(), Mint.Types.error()}
@spec recv(t(), GenServer.from()) :: :pop | {t(), t()}
Link to this function

stream_request_body(req, conn)

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