AmqpDirector.Client (amqp_director v1.6.0) View Source
The AMQP RPC Client.
This module contains functionality for an RPC client. See AmqpDirector.client_child_spec/3
for details on how to start the RPC client.
Link to this section Summary
Functions
Await until the client is started.
Send a synchronous request.
Send an asynchronous request.
Link to this section Types
Specs
call_error_reason() :: :no_route | :no_consumers | {:reply_code, number()}
Error types for the synchronous RPC call.
Specs
request_options() :: {:timeout, pos_integer() | :infinity} | {:persistent, boolean()} | {:ttl, pos_integer()} | {:return_headers, boolean()}
Options for an RPC request.
:ttl
- Specified the TTL of the message on AMQP.:timeout
- Time the client awaits response. Only valid forcall/6
. This is thegen_server
timeout. Should be larger than the value for:ttl
:persistent
- Specifies the delivery mode for the AMQP messages. Setting this totrue
will make the broker log the messages on disk. See AMQP specification for more information. Defaults tofalse
:return_headers
- Specified if the caller is interested into the amqp message header table
Link to this section Functions
Specs
await(client :: atom() | pid(), timeout :: pos_integer() | :infinity) :: any()
Await until the client is started.
This will block the caller for the specified time or until the RPC client starts. This can be use to ensure that the client is running before requests are made.
call(client, exchange, routing_key, payload, content_type, options \\ [timeout: 5000])
View SourceSpecs
call( client :: atom() | pid(), exchange :: String.t(), routing_key :: String.t(), payload :: binary() | {binary(), AmqpDirector.Definitions.amqp_table()}, content_type :: String.t(), options :: [request_options()] ) :: {:ok, content :: binary() | {binary(), AmqpDirector.Definitions.amqp_table()}, content_type :: String.t()} | {:error, call_error_reason()}
Send a synchronous request.
Sends a synchronous request to an AMQP broker and awaits for response for the length of :timeout
option (Defaults to 5 seconds). It sends the message
to the specified exchange with the specified routing key. The content_type
specifies the type of the payload. AMQP message type is always set to
"request"
in case of a call.
cast(client, exchange, routing_key, payload, content_type, type, options \\ [])
View SourceSpecs
cast( client :: atom() | pid(), exchange :: String.t(), routing_key :: String.t(), payload :: binary() | {binary(), AmqpDirector.Definitions.amqp_table()}, content_type :: String.t(), type :: String.t(), options :: [request_options()] ) :: :ok
Send an asynchronous request.
Sends an asynchronous request to an AMQP broker without expecting any response. It is send to the specified exchange using the specified routing key.
The content_type
specifies the type of the payload while the type
parameters refers to the AMQP message type header. See the AMQP reference for
details.