lapin v0.1.1 Lapin.Worker behaviour

Lapin Worker behaviour

To Implement a custom Lapin.Worker behaviour define a module:

defmodule MyApp.MyWorker do
  use Lapin.Worker

  [... callbacks implementation ...]
end

A custom Lapin.Pattern module can be specified using the pattern option:

defmodule MyApp.MyWorker do
  use Lapin.Worker, pattern: MyApp.MyPattern

  [... callbacks implementation ...]
end

Check out the Lapin.Pattern submodules for a number of implementantions of common interaction patterns.

Link to this section Summary

Types

Exchange name

Worker module callback result

Module conforming to Lapin.Pattern

Queue name

Channel role

Callbacks

Called when receiving a basic.cancel from the broker

Called when receiving a basic.cancel_ok from the broker

Called when receiving a basic.consume_ok from the broker

Called when receiving a basic.deliver from the broker

Called when completing a basic.publish with the broker

Called when receiving a basic.return from the broker

Returns the pattern for the worker module, defaults to Lapin.Pattern

Link to this section Types

Link to this type exchange()
exchange() :: String.t

Exchange name

Link to this type on_callback()
on_callback() :: :ok | {:error, message :: String.t}

Worker module callback result

Link to this type pattern()
pattern() :: Lapin.Pattern

Module conforming to Lapin.Pattern

Link to this type queue()
queue() :: String.t

Queue name

Link to this type role()
role() :: :consumer | :producer

Channel role

Link to this section Callbacks

Link to this callback handle_cancel(channel_config)
handle_cancel(channel_config :: Lapin.Connection.channel_config) :: on_callback

Called when receiving a basic.cancel from the broker.

Link to this callback handle_cancel_ok(channel_config)
handle_cancel_ok(channel_config :: Lapin.Connection.channel_config) :: on_callback

Called when receiving a basic.cancel_ok from the broker.

Link to this callback handle_consume_ok(channel_config)
handle_consume_ok(channel_config :: Lapin.Connection.channel_config) :: on_callback

Called when receiving a basic.consume_ok from the broker.

This signals successul registration as a consumer.

Link to this callback handle_deliver(channel_config, message)
handle_deliver(channel_config :: Lapin.Connection.channel_config, message :: Lapin.Message.t) :: on_callback

Called when receiving a basic.deliver from the broker.

Message consumption is successfully completed when this callback returns :ok

Link to this callback handle_publish(channel_config, message)
handle_publish(channel_config :: Lapin.Connection.channel_config, message :: Lapin.Message.t) :: on_callback

Called when completing a basic.publish with the broker.

Message transmission to the broker is successful when this callback is called.

Link to this callback handle_return(channel_config, message)
handle_return(channel_config :: Lapin.Connection.channel_config, message :: Lapin.Message.t) :: on_callback

Called when receiving a basic.return from the broker.

THis signals an undeliverable returned message from the broker.

Link to this callback pattern()
pattern() :: pattern

Returns the pattern for the worker module, defaults to Lapin.Pattern