freddy v0.9.1 Freddy.Notifications.Listener

Freddy.Consumer special case. Listens for notifications from “freddy-topic” exchange.

Like in Freddy.Consumer, you have to specify routing keys to bind to.

Example:

defmodule Notifications.Listener do
  use Freddy.Notifications.Listener

  @config [
    queue: [name: "myapp-notifications", opts: [auto_delete: true]],
    routing_keys: ["broadcast.*"]
  ]

  def start_link(conn, initial) do
    Freddy.Notifications.Listener.start_link(__MODULE__, conn, @config, initial)
  end
end

See also documentation for Freddy.Consumer

Link to this section Summary

Link to this section Types

Link to this type config()
config() :: [queue: Hare.Context.Action.DeclareQueue.config, routing_keys: [String.t], binds: [Keyword.t]]
Link to this type connection()
connection() :: Freddy.Consumer.connection
Link to this type options()
options() :: GenServer.options

Link to this section Functions

Link to this function call(consumer, message)

See Freddy.Consumer.call/2.

Link to this function call(consumer, message, timeout)

See Freddy.Consumer.call/3.

Link to this function cast(consumer, message)

See Freddy.Consumer.cast/2.

Link to this function start_link(mod, conn, config, initial, opts \\ [])
start_link(module, connection, config, initial :: term, options) :: GenServer.on_start

Start a Freddy.Notifications.Listener process linked to the current process.

Arguments:

  • mod - the module that defines the server callbacks (like GenServer)
  • connection - the pid of a Hare.Core.Conn process
  • config - the configuration of the listener
  • initial - the value that will be given to init/1
  • opts - the GenServer options