retort v2.6.3-rc2 Retort.Server.Generic behaviour View Source
Exposes an Ecto.Schema.t
as a JSONAPI resource over JSON RPC on a RabbitMQ queue.
Any code with side-effects, such as Logger
or Repo
calls should stay in this module. Any pure functions that
write back to the Retort.Server.Generic.RPC.t
can be in
Retort.Server.Generic.RPC
.
Link to this section Summary
Types
callback
- Themodule
that implement this behaviour and its own internal state.channel
- the AMQP channel connected toqueue
queue
- name of RabbitMQ queue to consume
Functions
Returns a specification to start this module under a supervisor
Most received messages filter through here to find the right function to call based on RPC method
Sets connection, channel, and queue to Rabbit
Attaches consumer to queue
in t
Callbacks
Should match on rpc.decoded.method
and return rpc with rpc.response.decoded.result
set
Link to this section Types
t() :: %Retort.Server.Generic{ callback: Retort.Server.Generic.Callback.t(), channel: %AMQP.Channel{conn: term(), pid: term()} | nil, queue: String.t() }
callback
- Themodule
that implement this behaviour and its own internal state.channel
- the AMQP channel connected toqueue
queue
- name of RabbitMQ queue to consume
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
handle_info( {:basic_cancel, %{:consumer_tag => any(), optional(term()) => term()}}, t() ) :: {:stop, :normal, t()}
handle_info( {:basic_cancel_ok, %{:consumer_tag => any(), optional(term()) => term()}}, t() ) :: {:noreply, t()}
handle_info( {:basic_consume_ok, %{:consumer_tag => any(), optional(term()) => term()}}, t() ) :: {:noreply, t()}
handle_info({:basic_deliver, any(), any()}, t()) :: {:noreply, t()}
handle_info({:DOWN, reference(), :process, pid(), any()}, t()) :: {:noreply, t()}
Most received messages filter through here to find the right function to call based on RPC method.
init(t()) :: {:ok, t()} | {:stop, any()} | {:ok, t(), :hibernate | :infinity | non_neg_integer()}
Sets connection, channel, and queue to Rabbit
start_link(t(), GenServer.options()) :: GenServer.on_start()
Attaches consumer to queue
in t
Link to this section Callbacks
handle_method(rpc :: Retort.Server.Generic.RPC.t(), callback_state :: any()) :: Retort.Server.Generic.RPC.t()
Should match on rpc.decoded.method
and return rpc with rpc.response.decoded.result
set.