Skip to content

Commit

Permalink
Merge pull request #73 from nsweeting/v0.13
Browse files Browse the repository at this point in the history
Fix handle_setup for ConsumerSupervisor
  • Loading branch information
nsweeting authored Mar 11, 2021
2 parents a931b87 + b20d2ff commit 021b7e4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The package can be installed by adding `rabbit` to your list of dependencies in
```elixir
def deps do
[
{:rabbit, "~> 0.12"}
{:rabbit, "~> 0.13"}
]
end
```
Expand Down
6 changes: 3 additions & 3 deletions lib/rabbit/consumer_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ defmodule Rabbit.ConsumerSupervisor do
A callback executed by each consumer after the channel is open, but before
consumption.
Please see `c:Rabbit.Consumer.handle_setup/2` for more information.
Please see `c:Rabbit.Consumer.handle_setup/1` for more information.
"""
@callback handle_setup(channel :: AMQP.Channel.t(), queue :: String.t()) :: :ok
@callback handle_setup(state :: map()) :: :ok | {:ok, new_state :: map()} | :error

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

@optional_callbacks handle_setup: 2
@optional_callbacks handle_setup: 1

################################
# Public API
Expand Down
2 changes: 1 addition & 1 deletion lib/rabbit/topology.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Rabbit.Topology do
bindings. Basically - performing any RabbitMQ setup required by your application.
It should be added to your supervision tree before any producers or consumers.
Both `Rabbit.Consumer` and `Rabbit.ConsumerSupervisor` have the `handle_setup/2`
Both `Rabbit.Consumer` and `Rabbit.ConsumerSupervisor` have the `handle_setup/1`
callback, which can be used to perform any queue, exchange or binding work as
well. But if you have more complex requirements, this module can be used.
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Rabbit.MixProject do
use Mix.Project

@version "0.12.0"
@version "0.13.0"

def project do
[
Expand Down
6 changes: 3 additions & 3 deletions test/consumer_supervisor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ defmodule Rabbit.ConsumerSupervisorTest do
end

@impl Rabbit.ConsumerSupervisor
def handle_setup(chan, queue) do
AMQP.Queue.declare(chan, queue, auto_delete: true)
AMQP.Queue.purge(chan, queue)
def handle_setup(state) do
AMQP.Queue.declare(state.chan, state.queue, auto_delete: true)
AMQP.Queue.purge(state.chan, state.queue)

:ok
end
Expand Down

0 comments on commit 021b7e4

Please sign in to comment.