diff options
| author | Matthias Radestock <matthias@lshift.net> | 2010-02-02 16:05:23 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2010-02-02 16:05:23 +0000 |
| commit | 19642833f120e6b52fd41e77f37d57b40504f74e (patch) | |
| tree | b34aa860abe928772cd33543aefb5b402900725b | |
| parent | b2b6200f753c96c79e2ae53b2ce1a9d42f6bbdd9 (diff) | |
| download | rabbitmq-server-git-19642833f120e6b52fd41e77f37d57b40504f74e.tar.gz | |
extend channel API with funs to get hold of consumers
| -rw-r--r-- | src/rabbit_channel.erl | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 2035d5611c..2cea0e3741 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -37,7 +37,8 @@ -export([start_link/5, do/2, do/3, shutdown/1]). -export([send_command/2, deliver/4, conserve_memory/2]). --export([list/0, info/1, info/2, info_all/0, info_all/1]). +-export([list/0, info/1, info/2, info_all/0, info_all/1, + consumers/1, consumers_all/0]). -export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2, handle_info/2]). @@ -78,6 +79,8 @@ -spec(info/2 :: (pid(), [info_key()]) -> [info()]). -spec(info_all/0 :: () -> [[info()]]). -spec(info_all/1 :: ([info_key()]) -> [[info()]]). +-spec(consumers/1 :: (pid()) -> [{binary(), queue_name()}]). +-spec(consumers_all/0 :: () -> [{pid(), binary(), queue_name()}]). -endif. @@ -125,6 +128,16 @@ info_all() -> info_all(Items) -> rabbit_misc:filter_exit_map(fun (C) -> info(C, Items) end, list()). +consumers(Pid) -> + gen_server2:pcall(Pid, 9, consumers, infinity). + +consumers_all() -> + lists:concat( + rabbit_misc:filter_exit_map( + fun (C) -> + [{C, Tag, QueueName} || {Tag, QueueName} <- consumers(C)] + end, list())). + %%--------------------------------------------------------------------------- init([Channel, ReaderPid, WriterPid, Username, VHost]) -> @@ -156,6 +169,10 @@ handle_call({info, Items}, _From, State) -> catch Error -> reply({error, Error}, State) end; +handle_call(consumers, _From, + State = #ch{consumer_mapping = ConsumerMapping}) -> + reply(dict:to_list(ConsumerMapping), State); + handle_call(_Request, _From, State) -> noreply(State). |
