View Source GRPC.Server.Adapters.Cowboy.Handler (grpc v0.9.0)
A cowboy handler accepting all requests and calls corresponding functions defined by users.
Summary
Functions
Return all bindings of a given request.
Return the client TLS certificate. :undefined
is returned if no certificate was specified
when establishing the connection.
Return all request headers.
Return the peer IP address and port number
Return the query string for the request URI.
Callback implementation for :cowboy_loop.info/3
.
This function is meant to be called whenever a new request arrives to an existing connection.
This handler works mainly with two linked processes.
One of them is the process started by cowboy which internally we'll refer to it as stream_pid
,
this process is responsible to interface the interactions with the open socket.
The second process is the one we start in this function, we'll refer to it as server_rpc_pid
,
which is the point where we call the functions implemented by users (aka the modules who use
the GRPC.Server
macro)
Synchronously reads a chunk of body content of a given request. Raise in case of a timeout.
Synchronously reads the whole body content of a given request. Raise in case of a timeout.
Asynchronously set the compressor algorithm to be used for compress the responses. This checks if
the grpc-accept-encoding
header is present on the original request, otherwise no compression
is applied.
Asynchronously set the headers for a given request. This function does not send any data back to the client. It simply appends the headers to be used in the response.
Asynchronously set the trailer headers for a given request. This function does not send any data back to the client. It simply appends the trailer headers to be used in the response.
Asynchronously send back to client a chunk of data
, when http_transcode?
is true, the
data is sent back as it's, with no transformation of protobuf binaries to http2 data frames.
Asynchronously send back to the client the http status and the headers for a given request.
Asynchronously stream the given trailers of request back to client.
Callback implementation for :cowboy_loop.terminate/3
.
Types
@type init_result() :: {:cowboy_loop, :cowboy_req.req(), stream_state()} | {:ok, :cowboy_req.req(), init_state()}
@type is_fin() :: :fin | :nofin
@type stream_state() :: %{ pid: server_rpc_pid :: pid(), handling_timer: timeout_timer_ref :: reference(), pending_reader: nil | pending_reader() }
Functions
@spec get_bindings(stream_pid :: pid()) :: :cowboy_router.bindings()
Return all bindings of a given request.
Return the client TLS certificate. :undefined
is returned if no certificate was specified
when establishing the connection.
@spec get_headers(stream_pid :: pid()) :: :cowboy.http_headers()
Return all request headers.
@spec get_peer(stream_pid :: pid()) :: {:inet.ip_address(), :inet.port_number()}
Return the peer IP address and port number
Return the query string for the request URI.
Callback implementation for :cowboy_loop.info/3
.
@spec init(:cowboy_req.req(), state :: init_state()) :: init_result()
This function is meant to be called whenever a new request arrives to an existing connection.
This handler works mainly with two linked processes.
One of them is the process started by cowboy which internally we'll refer to it as stream_pid
,
this process is responsible to interface the interactions with the open socket.
The second process is the one we start in this function, we'll refer to it as server_rpc_pid
,
which is the point where we call the functions implemented by users (aka the modules who use
the GRPC.Server
macro)
Synchronously reads a chunk of body content of a given request. Raise in case of a timeout.
Synchronously reads the whole body content of a given request. Raise in case of a timeout.
Asynchronously set the compressor algorithm to be used for compress the responses. This checks if
the grpc-accept-encoding
header is present on the original request, otherwise no compression
is applied.
Asynchronously set the headers for a given request. This function does not send any data back to the client. It simply appends the headers to be used in the response.
Asynchronously set the trailer headers for a given request. This function does not send any data back to the client. It simply appends the trailer headers to be used in the response.
@spec stream_body( stream_pid :: pid(), data :: iodata(), opts :: [stream_body_opts()], is_fin(), http_transcode? :: boolean() ) :: :ok
Asynchronously send back to client a chunk of data
, when http_transcode?
is true, the
data is sent back as it's, with no transformation of protobuf binaries to http2 data frames.
@spec stream_reply( stream_pid :: pid(), status :: non_neg_integer(), headers :: headers() ) :: :ok
Asynchronously send back to the client the http status and the headers for a given request.
Asynchronously stream the given trailers of request back to client.
Callback implementation for :cowboy_loop.terminate/3
.