Skip to content

Commit 1f97bf3

Browse files
Merge pull request #14281 from rabbitmq/mergify/bp/v4.1.x/pr-14280
Classic queues: return basic info items without calling queue process (backport #14280)
2 parents 3c349b3 + b7f3e10 commit 1f97bf3

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

deps/rabbit/src/rabbit_classic_queue.erl

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@
1818
monitored = #{} :: #{pid() => ok}
1919
}).
2020

21+
-define(STATIC_KEYS, [name,
22+
durable,
23+
auto_delete,
24+
arguments,
25+
pid,
26+
leader,
27+
members,
28+
owner_pid,
29+
exclusive,
30+
policy,
31+
operator_policy,
32+
effective_policy_definition,
33+
type]).
2134

2235
-opaque state() :: #?STATE{}.
2336

@@ -491,6 +504,16 @@ state_info(_State) ->
491504
-spec info(amqqueue:amqqueue(), all_keys | rabbit_types:info_keys()) ->
492505
rabbit_types:infos().
493506
info(Q, Items) ->
507+
AllStaticItems = is_list(Items) andalso
508+
lists:all(fun(I) -> lists:member(I, ?STATIC_KEYS) end, Items),
509+
case AllStaticItems of
510+
true ->
511+
static_info(Q, Items);
512+
false ->
513+
info_call(Q, Items)
514+
end.
515+
516+
info_call(Q, Items) ->
494517
QPid = amqqueue:get_pid(Q),
495518
Req = case Items of
496519
all_keys -> info;
@@ -506,6 +529,48 @@ info(Q, Items) ->
506529
Result
507530
end.
508531

532+
static_info(Q, Items) ->
533+
[{I, i(I, Q)} || I <- Items].
534+
535+
i(name, Q) ->
536+
amqqueue:get_name(Q);
537+
i(durable, Q) ->
538+
amqqueue:is_durable(Q);
539+
i(auto_delete, Q) ->
540+
amqqueue:is_auto_delete(Q);
541+
i(arguments, Q) ->
542+
amqqueue:get_arguments(Q);
543+
i(pid, Q) ->
544+
amqqueue:get_pid(Q);
545+
i(leader, Q) ->
546+
node(i(pid, Q));
547+
i(members, Q) ->
548+
[i(leader, Q)];
549+
i(owner_pid, Q) when ?amqqueue_exclusive_owner_is(Q, none) ->
550+
'';
551+
i(owner_pid, Q) ->
552+
amqqueue:get_exclusive_owner(Q);
553+
i(exclusive, Q) ->
554+
ExclusiveOwner = amqqueue:get_exclusive_owner(Q),
555+
is_pid(ExclusiveOwner);
556+
i(policy, Q) ->
557+
case rabbit_policy:name(Q) of
558+
none -> '';
559+
Policy -> Policy
560+
end;
561+
i(operator_policy, Q) ->
562+
case rabbit_policy:name_op(Q) of
563+
none -> '';
564+
Policy -> Policy
565+
end;
566+
i(effective_policy_definition, Q) ->
567+
case rabbit_policy:effective_definition(Q) of
568+
undefined -> [];
569+
Def -> Def
570+
end;
571+
i(type, _) ->
572+
classic.
573+
509574
-spec purge(amqqueue:amqqueue()) ->
510575
{ok, non_neg_integer()}.
511576
purge(Q) when ?is_amqqueue(Q) ->

0 commit comments

Comments
 (0)