Skip to content

Commit 021b7e4

Browse files
authored
Merge pull request #73 from nsweeting/v0.13
Fix handle_setup for ConsumerSupervisor
2 parents a931b87 + b20d2ff commit 021b7e4

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The package can be installed by adding `rabbit` to your list of dependencies in
1212
```elixir
1313
def deps do
1414
[
15-
{:rabbit, "~> 0.12"}
15+
{:rabbit, "~> 0.13"}
1616
]
1717
end
1818
```

lib/rabbit/consumer_supervisor.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ defmodule Rabbit.ConsumerSupervisor do
119119
A callback executed by each consumer after the channel is open, but before
120120
consumption.
121121
122-
Please see `c:Rabbit.Consumer.handle_setup/2` for more information.
122+
Please see `c:Rabbit.Consumer.handle_setup/1` for more information.
123123
"""
124-
@callback handle_setup(channel :: AMQP.Channel.t(), queue :: String.t()) :: :ok
124+
@callback handle_setup(state :: map()) :: :ok | {:ok, new_state :: map()} | :error
125125

126126
@doc """
127127
A callback executed by each consumer to handle message consumption.
@@ -137,7 +137,7 @@ defmodule Rabbit.ConsumerSupervisor do
137137
"""
138138
@callback handle_error(message :: Rabbit.Message.t()) :: Rabbit.Consumer.message_response()
139139

140-
@optional_callbacks handle_setup: 2
140+
@optional_callbacks handle_setup: 1
141141

142142
################################
143143
# Public API

lib/rabbit/topology.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Rabbit.Topology do
66
bindings. Basically - performing any RabbitMQ setup required by your application.
77
It should be added to your supervision tree before any producers or consumers.
88
9-
Both `Rabbit.Consumer` and `Rabbit.ConsumerSupervisor` have the `handle_setup/2`
9+
Both `Rabbit.Consumer` and `Rabbit.ConsumerSupervisor` have the `handle_setup/1`
1010
callback, which can be used to perform any queue, exchange or binding work as
1111
well. But if you have more complex requirements, this module can be used.
1212

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Rabbit.MixProject do
22
use Mix.Project
33

4-
@version "0.12.0"
4+
@version "0.13.0"
55

66
def project do
77
[

test/consumer_supervisor_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ defmodule Rabbit.ConsumerSupervisorTest do
3030
end
3131

3232
@impl Rabbit.ConsumerSupervisor
33-
def handle_setup(chan, queue) do
34-
AMQP.Queue.declare(chan, queue, auto_delete: true)
35-
AMQP.Queue.purge(chan, queue)
33+
def handle_setup(state) do
34+
AMQP.Queue.declare(state.chan, state.queue, auto_delete: true)
35+
AMQP.Queue.purge(state.chan, state.queue)
3636

3737
:ok
3838
end

0 commit comments

Comments
 (0)