diff options
| author | Matthias Radestock <matthias@lshift.net> | 2008-11-11 22:57:49 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2008-11-11 22:57:49 +0000 |
| commit | 17f996b9df7c8b9661b5edc8f2f90b6ca919099a (patch) | |
| tree | 4f08fed74c793ef98f2261b93e247e37a496e860 | |
| parent | 252620e5a067cdae5984757b6b395bad66e747b7 (diff) | |
| download | rabbitmq-server-git-17f996b9df7c8b9661b5edc8f2f90b6ca919099a.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.erl | 18 | ||||
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 25 |
2 files changed, 24 insertions, 19 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index f241e69576..2b5b628ddf 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 b733d1146d..11573ef234 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) |
