Skip to content

Commit d66b38d

Browse files
committed
See #7323. Rename default policy for ha-* and add option to massage key/value for aggregate_props
1 parent 232c7fa commit d66b38d

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

deps/rabbit/priv/schema/rabbit.schema

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,16 +743,22 @@ end}.
743743
{datatype, integer}
744744
]}.
745745

746-
{mapping, "default_policies.operator.$id.ha_mode", "rabbit.default_policies.operator", [
746+
{mapping, "default_policies.operator.$id.classic_queues.ha_mode", "rabbit.default_policies.operator", [
747747
{datatype, string}
748748
]}.
749749

750-
{mapping, "default_policies.operator.$id.ha_params", "rabbit.default_policies.operator", [
750+
{mapping, "default_policies.operator.$id.classic_queues.ha_params", "rabbit.default_policies.operator", [
751751
{datatype, [integer, {list, string}]}
752752
]}.
753753

754754
{translation, "rabbit.default_policies.operator", fun(Conf) ->
755-
Props = rabbit_cuttlefish:aggregate_props(Conf, ["default_policies", "operator"]),
755+
Props = rabbit_cuttlefish:aggregate_props(
756+
Conf,
757+
["default_policies", "operator"],
758+
fun({["default_policies","operator",ID,"classic_queues"|T], V}) ->
759+
{["default_policies","operator",ID|T],V};
760+
(E) -> E
761+
end),
756762
Props1 = lists:map(
757763
fun({K, Ss}) ->
758764
{K,

deps/rabbit/src/rabbit_cuttlefish.erl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,28 @@
88
-module(rabbit_cuttlefish).
99

1010
-export([
11-
aggregate_props/2
11+
aggregate_props/2,
12+
aggregate_props/3
1213
]).
1314

1415
-type keyed_props() :: [{binary(), [{binary(), any()}]}].
1516

1617
-spec aggregate_props([{string(), any()}], [string()]) ->
1718
keyed_props().
1819
aggregate_props(Conf, Prefix) ->
20+
aggregate_props(Conf, Prefix, fun(E) -> E end).
21+
22+
-spec aggregate_props([{string(), any()}], [string()], function()) ->
23+
keyed_props().
24+
aggregate_props(Conf, Prefix, KeyFun) ->
1925
Pattern = Prefix ++ ["$id", "$_"],
2026
PrefixLen = length(Prefix),
2127
FlatList = lists:filtermap(
22-
fun({K, V}) ->
28+
fun(E) ->
29+
{K, V} = KeyFun(E),
2330
case cuttlefish_variable:is_fuzzy_match(K, Pattern) of
2431
true -> {true, {lists:nthtail(PrefixLen, K), V}};
25-
_ -> false
32+
false -> false
2633
end
2734
end,
2835
Conf

deps/rabbit/test/config_schema_SUITE_data/rabbit.snippets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@ ssl_options.fail_if_no_peer_cert = true",
123123
default_policies.operator.a.expires = 1h
124124
default_policies.operator.a.queue_pattern = apple
125125
default_policies.operator.a.vhost_pattern = banana
126+
default_policies.operator.a.classic_queues.ha_mode = exactly
127+
default_policies.operator.a.classic_queues.ha_params = 2
126128
",
127129
[{rabbit, [{default_policies, [{operator, [
128130
{<<"a">>, [{<<"expires">>, 3600000},
131+
{<<"ha-mode">>, "exactly"},
132+
{<<"ha-params">>, 2},
129133
{<<"queue-pattern">>, "apple"},
130134
{<<"vhost-pattern">>, "banana"}]}]}]}]}],
131135
[]},

0 commit comments

Comments
 (0)