View Source WhiteRabbit behaviour (White Rabbit v0.2.0)
Link to this section Summary
Types
Returned by start_link/2
.
Callbacks
Returns a list of connections to start.any()
Returns a map of a rpc_config to configure the correct rpc queues and consumers.
Returns a list of tuples defining WhiteRabbit.Consumer
GenServers to be started on app startup.
Link to this section Types
Returned by start_link/2
.
Link to this section Callbacks
@callback get_connections() :: [WhiteRabbit.Connection.t()]
Returns a list of connections to start.any()
Example:
def get_connections do
[
%Connection{
connection_name: :appone_connection,
conn_opts: [url: "amqp://user:pass@localhost:5673/dev"],
channels: [
%{
name: :appone_consumer_channel
},
%{
name: :appone_producer_channel
}
]
},
%Connection{
connection_name: :appone_rpc_connection,
conn_opts: [url: "amqp://user:pass@localhost:5673/dev"],
channels: [
%{
name: :appone_rpc_consumer_channel_1
},
%{
name: :appone_rpc_consumer_channel_2
}
]
}
]
end
@callback get_rpc_config() :: WhiteRabbit.RPC.Config.t()
Returns a map of a rpc_config to configure the correct rpc queues and consumers.
Example
# Use callback spec to return %WhiteRabbit.RPC.Config{} struct
@impl true
def get_rpc_config do
%WhiteRabbit.RPC.Config{
service_name: "appone",
connection_name: :appone_rpc_connection
}
end
@callback get_startup_consumers() :: [{any(), WhiteRabbit.Consumer.t()}]
Returns a list of tuples defining WhiteRabbit.Consumer
GenServers to be started on app startup.
Example
@impl true
def get_startup_consumers do
[
{WhiteRabbit.Consumer,
%WhiteRabbit.Consumer{
connection_name: :appone_connection,
name: "AppOne.JsonConsumer",
exchange: "json_test_exchange",
queue: "json_test_queue",
processor: %WhiteRabbit.Processor.Config{module: AppOne.TestJsonProcessor}
}}
]
end
Link to this section Functions
Link to this function
start_dynamic_consumers(config, concurreny \\ 1, module \\ __MODULE__)
View SourceStart the WhiteRabbit Hole.
Calls WhiteRabbit.Hole.start_link
to start the supervision topology defined.