retort v2.7.0 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- Themodulethat implement this behaviour and its own internal state.channel- the AMQP channel connected toqueuequeue- name of RabbitMQ queue to consume
Functions
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- Themodulethat implement this behaviour and its own internal state.channel- the AMQP channel connected toqueuequeue- name of RabbitMQ queue to consume
Link to this section Functions
handle_info({:DOWN, reference(), :process, pid(), any()}, t()) :: {:noreply, t()}
handle_info({:basic_deliver, any(), any()}, t()) :: {:noreply, t()}
handle_info({:basic_consume_ok, %{:consumer_tag => any(), optional(term()) => term()}}, t()) :: {:noreply, t()}
handle_info({:basic_cancel_ok, %{:consumer_tag => any(), optional(term()) => term()}}, t()) :: {:noreply, t()}
handle_info({:basic_cancel, %{:consumer_tag => any(), optional(term()) => term()}}, t()) :: {:stop, :normal, t()}
Most received messages filter through here to find the right function to call based on RPC method.
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.
init(generic_state :: t(), callback_state) :: {:ok, callback_state} | {:ok, callback_state, timeout() | :hibernate} | :ignore | {:stop, reason :: any()} when callback_state: any()