retort v2.7.0 Retort.Server.Generic.RPC View Source
A request, its meta data and its response for RabbitMQ. Lke a Plug.Conn, but for RPC.
Any pure functions that write back to the Retort.Server.Generic.RPC.t can be in this module. Any
code with side-effects, such as Logger or Repo calls should go in Retort.Server.Generic.
Link to this section Summary
Functions
Adds key to assigns with value
Extracts an Alembic.Document.t from request.decoded.params and assigns it to assigns.document
Decodes the request.encoded to an Retort.Request and puts it in request.decoded
Makes sure that the keys in the request.decoded.params are underscored as required by
Alembic
Converts the :basic_deliver arguments passed to Retort.Server.Generic.handle_info/2 by AMQP to
a t
Halts the rpc after setting the response.decoded to the output of function
Checks that the response.decoded.id matches the meta.correlation_id
Converts the request.decoded to a response.decoded with the same id
Times duration of function and puts that timing information in timing section of t
Link to this section Types
t() :: %Retort.Server.Generic.RPC{assigns: %{optional(atom()) => any()}, halted: boolean(), meta: %{correlation_id: binary(), delivery_tag: term(), reply_to: term()} | nil, request: %{decoded: Retort.Request.t() | nil, encoded: binary()}, response: %{decoded: Retort.Response.t() | nil, encoded: binary() | nil}, timing: %{ending_monotonic_time: integer() | nil, starting_monotonic_time: integer() | nil}}
Link to this section Functions
Adds key to assigns with value
Extracts an Alembic.Document.t from request.decoded.params and assigns it to assigns.document.
If there is an error extracting the document, the response.decoded is set to an error Alembic.Document.t and the
t is halted.
Decodes the request.encoded to an Retort.Request and puts it in request.decoded.
If there is an error, the response.decoded is set to an error Alembic.Document.t and the t is halted.
Makes sure that the keys in the request.decoded.params are underscored as required by
Alembic
from_basic_deliver({:basic_deliver, binary(), map()}, Retort.Server.Generic.t()) :: t()
Converts the :basic_deliver arguments passed to Retort.Server.Generic.handle_info/2 by AMQP to
a t.
halt(t(), (Retort.Response.t() -> Retort.Response.t())) :: t()
Halts the rpc after setting the response.decoded to the output of function
match_correlation_id(%Retort.Server.Generic.RPC{assigns: term(), halted: false, meta: %{:correlation_id => binary(), optional(any()) => any()}, request: %{decoded: Retort.Response.t()}, response: term(), timing: term()}) :: t()
match_correlation_id(%Retort.Server.Generic.RPC{assigns: term(), halted: true, meta: term(), request: term(), response: term(), timing: term()}) :: t()
Checks that the response.decoded.id matches the meta.correlation_id
Converts the request.decoded to a response.decoded with the same id
Times duration of function and puts that timing information in timing section of t
The timing.starting_monotonic_time will be set on the t passed to function. The t returned by function will
have timing.ending_monotonic_time set on it before being returned.