View Source WhiteRabbit behaviour (White Rabbit v0.2.0)

Link to this section Summary

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

@type on_start() ::
  {:ok, pid()} | :ignore | {:error, {:already_started, pid()} | term()}

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
Link to this callback

get_rpc_config()

View Source (optional)
@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
Link to this callback

get_startup_consumers()

View Source (optional)
@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
@callback process_name(String.t(), module()) :: atom()
Link to this callback

start_dynamic_consumers(map, integer)

View Source
@callback start_dynamic_consumers(map(), integer()) :: [{:ok, pid()}]

Link to this section Functions

Link to this function

process_name(name, prefix \\ __MODULE__)

View Source
Link to this function

start_dynamic_consumers(config, concurreny \\ 1, module \\ __MODULE__)

View Source
Link to this function

start_link(module, opts)

View Source

Start the WhiteRabbit Hole.

Calls WhiteRabbit.Hole.start_link to start the supervision topology defined.