summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2008-11-11 22:57:49 +0000
committerMatthias Radestock <matthias@lshift.net>2008-11-11 22:57:49 +0000
commit60e744f1b38b32eb036701af4ac9d1bc1084d1e6 (patch)
tree4f08fed74c793ef98f2261b93e247e37a496e860
parent4c183564e75aecd662bcc73268f2d817c8b4cdfe (diff)
downloadrabbitmq-server-60e744f1b38b32eb036701af4ac9d1bc1084d1e6.tar.gz
simplify info and info_all API, and extend info item list
- no overloading - info_all now returns a list of kvlists rather than a list of queuname-kvlist pairs - new info items for all the bits of the amqqueue structure
-rw-r--r--src/rabbit_amqqueue.erl18
-rw-r--r--src/rabbit_amqqueue_process.erl25
2 files changed, 24 insertions, 19 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index f241e695..2b5b628d 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -68,13 +68,9 @@
-spec(list/0 :: () -> [amqqueue()]).
-spec(list_vhost_queues/1 :: (vhost()) -> [amqqueue()]).
-spec(info/1 :: (amqqueue()) -> [info()]).
--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(info/2 :: (amqqueue(), [info_key()]) -> [info()]).
+-spec(info_all/0 :: () -> [[info()]]).
+-spec(info_all/1 :: ([info_key()]) -> [[info()]]).
-spec(stat/1 :: (amqqueue()) -> qstats()).
-spec(stat_all/0 :: () -> [qstats()]).
-spec(delete/3 ::
@@ -209,15 +205,15 @@ list_vhost_queues(VHostPath) ->
info(#amqqueue{ pid = QPid }) ->
gen_server:call(QPid, info).
-info(#amqqueue{ pid = QPid }, ItemOrItems) ->
- case gen_server:call(QPid, {info, ItemOrItems}) of
+info(#amqqueue{ pid = QPid }, Items) ->
+ case gen_server:call(QPid, {info, Items}) of
{ok, Res} -> Res;
{error, Error} -> throw(Error)
end.
-info_all() -> map(fun (Q) -> {Q, info(Q)} end).
+info_all() -> map(fun (Q) -> info(Q) end).
-info_all(ItemOrItems) -> map(fun (Q) -> {Q, info(Q, ItemOrItems)} end).
+info_all(Items) -> map(fun (Q) -> info(Q, Items) end).
stat(#amqqueue{pid = QPid}) -> gen_server:call(QPid, stat).
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index b733d114..11573ef2 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -62,7 +62,12 @@
unsent_message_count}).
-define(INFO_KEYS,
- [messages_ready,
+ [name,
+ durable,
+ auto_delete,
+ arguments,
+ pid,
+ messages_ready,
messages_unacknowledged,
messages_uncommitted,
messages,
@@ -473,6 +478,16 @@ purge_message_buffer(QName, MessageBuffer) ->
infos(Items, State) -> [{Item, info(Item, State)} || Item <- Items].
+info(name, #q{q = #amqqueue{name = Name}}) ->
+ Name;
+info(durable, #q{q = #amqqueue{durable = Durable}}) ->
+ Durable;
+info(auto_delete, #q{q = #amqqueue{auto_delete = AutoDelete}}) ->
+ AutoDelete;
+info(arguments, #q{q = #amqqueue{arguments = Arguments}}) ->
+ Arguments;
+info(pid, #q{q = #amqqueue{pid = Pid}}) ->
+ Pid;
info(messages_ready, #q{message_buffer = MessageBuffer}) ->
queue:len(MessageBuffer);
info(messages_unacknowledged, _) ->
@@ -504,13 +519,7 @@ info(Item, _) ->
handle_call(info, _From, State) ->
reply(infos(?INFO_KEYS, State), State);
-handle_call({info, Item}, _From, State) when is_atom(Item) ->
- try
- reply({ok, {Item, info(Item, State)}}, State)
- catch Error -> reply({error, Error}, State)
- end;
-
-handle_call({info, Items}, _From, State) when is_list(Items) ->
+handle_call({info, Items}, _From, State) ->
try
reply({ok, infos(Items, State)}, State)
catch Error -> reply({error, Error}, State)