Permalink
Browse files

unique names for running workers

  • Loading branch information...
1 parent 8005434 commit 0babf12e07ad74dfadd506210c4cb4832d7e8b7c @mabrek committed Feb 28, 2011
Showing with 8 additions and 5 deletions.
  1. +1 −1 src/rabbit_redis_sup.erl
  2. +2 −1 src/rabbit_redis_worker.erl
  3. +5 −3 test/rabbit_redis_test.erl
View
2 src/rabbit_redis_sup.erl
@@ -12,7 +12,7 @@ start_link(Bridges) ->
supervisor2:start_link(
{local, ?MODULE},
?MODULE,
- [{erlang:md5(term_to_binary(Config)),
+ [{proplists:get_value(name, Config),
{rabbit_redis_worker, start_link, [Config]},
transient,
16#ffffffff,
View
3 src/rabbit_redis_worker.erl
@@ -11,7 +11,8 @@
-include("rabbit_redis.hrl").
start_link(Config) ->
- gen_server2:start_link({local, ?MODULE}, ?MODULE, Config, []).
+ gen_server2:start_link(
+ {local, proplists:get_value(name, Config)}, ?MODULE, Config, []).
init(Config) ->
gen_server2:cast(self(), init),
View
8 test/rabbit_redis_test.erl
@@ -37,7 +37,8 @@ empty_config() ->
with_configuration([], fun() -> ok end).
subscribe() ->
- with_configuration([[{type, subscribe},
+ with_configuration([[{name, subscribe_bridge},
+ {type, subscribe},
{redis, [{host, ?REDIS_HOST},
{port, ?REDIS_PORT},
{channels, [?CHANNEL]}]},
@@ -49,7 +50,7 @@ subscribe() ->
fun() -> with_rabbit_redis(fun subscribe_fun/2) end).
subscribe_fun(Channel, Redis) ->
- pong = gen_server2:call(rabbit_redis_worker, ping), % ensure started
+ pong = gen_server2:call(subscribe_bridge, ping), % ensure started
#'queue.declare_ok'{queue = Q} =
amqp_channel:call(Channel, #'queue.declare'{exclusive = true}),
@@ -75,7 +76,8 @@ subscribe_fun(Channel, Redis) ->
ok.
publish() ->
- with_configuration([[{type, publish},
+ with_configuration([[{name, publish_bridge},
+ {type, publish},
{redis, [{host, ?REDIS_HOST},
{port, ?REDIS_PORT}]},
{rabbit, [{declarations, [{'queue.declare',

0 comments on commit 0babf12

Please sign in to comment.