Skip to content

Commit a440bc6

Browse files
author
Daniil Fedotov
committed
Format runtime parameters using info items
Runtime parameters list functions do not accept info items as arguments. To return correct number and items order in the new CLI parameters should be sorted by info items order.
1 parent 993abe9 commit a440bc6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/rabbit_runtime_parameters.erl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,20 +306,32 @@ list_global() ->
306306
end).
307307

308308
list_formatted(VHost) ->
309-
[pset(value, rabbit_json:encode(pget(value, P)), P) || P <- list(VHost)].
309+
[ format_parameter(info_keys(), P) || P <- list(VHost) ].
310+
311+
format_parameter(InfoKeys, P) ->
312+
lists:foldr(fun
313+
(value, Acc) ->
314+
[{value, rabbit_json:encode(pget(value, P))} | Acc];
315+
(Key, Acc) ->
316+
case lists:keyfind(Key, 1, P) of
317+
false -> Acc;
318+
{Key, Val} -> [{Key, Val} | Acc]
319+
end
320+
end,
321+
[], InfoKeys).
310322

311323
list_formatted(VHost, Ref, AggregatorPid) ->
312324
rabbit_control_misc:emitting_map(
313325
AggregatorPid, Ref,
314-
fun(P) -> pset(value, rabbit_json:encode(pget(value, P)), P) end, list(VHost)).
326+
fun(P) -> format_parameter(info_keys(), P) end, list(VHost)).
315327

316328
list_global_formatted() ->
317-
[pset(value, rabbit_json:encode(pget(value, P)), P) || P <- list_global()].
329+
[ format_parameter(global_info_keys(), P) || P <- list_global() ].
318330

319331
list_global_formatted(Ref, AggregatorPid) ->
320332
rabbit_control_misc:emitting_map(
321333
AggregatorPid, Ref,
322-
fun(P) -> pset(value, rabbit_json:encode(pget(value, P)), P) end, list_global()).
334+
fun(P) -> format_parameter(global_info_keys(), P) end, list_global()).
323335

324336
lookup(VHost, Component, Name) ->
325337
case lookup0({VHost, Component, Name}, rabbit_misc:const(not_found)) of

0 commit comments

Comments
 (0)