diff options
| author | Matthias Radestock <matthias@lshift.net> | 2008-11-07 10:36:41 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2008-11-07 10:36:41 +0000 |
| commit | 252620e5a067cdae5984757b6b395bad66e747b7 (patch) | |
| tree | 64fa2cc47b7f29c01b5a000259021de262aad2f3 | |
| parent | 74eaf36721d6082bef307572e1ff3e95e1c8f31b (diff) | |
| download | rabbitmq-server-git-252620e5a067cdae5984757b6b395bad66e747b7.tar.gz | |
info_all
this is resilient to disappearing queues
| -rw-r--r-- | src/rabbit_amqqueue.erl | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 93caf51964..f241e69576 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -29,7 +29,7 @@ -export([pseudo_queue/2]). -export([lookup/1, with/2, with_or_die/2, list/0, list_vhost_queues/1, stat/1, stat_all/0, deliver/5, redeliver/2, requeue/3, ack/4]). --export([info/1, info/2]). +-export([info/1, info/2, info_all/0, info_all/1]). -export([claim_queue/2]). -export([basic_get/3, basic_consume/7, basic_cancel/4]). -export([notify_sent/2]). @@ -71,6 +71,10 @@ -spec(info/2 :: (amqqueue(), info_key()) -> info(); (amqqueue(), [info_key()]) -> [info()]). +-spec(info_all/0 :: () -> [{amqqueue(), [info()]}]). +-spec(info_all/1 :: + (info_key()) -> [{amqqueue(), info()}]; + ([info_key()]) -> [{amqqueue(), [info()]}]). -spec(stat/1 :: (amqqueue()) -> qstats()). -spec(stat_all/0 :: () -> [qstats()]). -spec(delete/3 :: @@ -189,6 +193,15 @@ with_or_die(Name, F) -> list() -> rabbit_misc:dirty_read_all(amqqueue). +map(F) -> + %% TODO: there is scope for optimisation here, e.g. using a + %% cursor, parallelising the function invocation + Ref = make_ref(), + lists:filter(fun (R) -> R =/= Ref end, + [rabbit_misc:with_exit_handler( + fun () -> Ref end, + fun () -> F(Q) end) || Q <- list()]). + list_vhost_queues(VHostPath) -> mnesia:dirty_match_object( #amqqueue{name = rabbit_misc:r(VHostPath, queue), _ = '_'}). @@ -202,6 +215,10 @@ info(#amqqueue{ pid = QPid }, ItemOrItems) -> {error, Error} -> throw(Error) end. +info_all() -> map(fun (Q) -> {Q, info(Q)} end). + +info_all(ItemOrItems) -> map(fun (Q) -> {Q, info(Q, ItemOrItems)} end). + stat(#amqqueue{pid = QPid}) -> gen_server:call(QPid, stat). stat_all() -> |
