See #7323. Rename default policy for ha-* and add option to massage key/value for aggregate_props
This commit is contained in:
parent
232c7faece
commit
d66b38d333
|
@ -743,16 +743,22 @@ end}.
|
|||
{datatype, integer}
|
||||
]}.
|
||||
|
||||
{mapping, "default_policies.operator.$id.ha_mode", "rabbit.default_policies.operator", [
|
||||
{mapping, "default_policies.operator.$id.classic_queues.ha_mode", "rabbit.default_policies.operator", [
|
||||
{datatype, string}
|
||||
]}.
|
||||
|
||||
{mapping, "default_policies.operator.$id.ha_params", "rabbit.default_policies.operator", [
|
||||
{mapping, "default_policies.operator.$id.classic_queues.ha_params", "rabbit.default_policies.operator", [
|
||||
{datatype, [integer, {list, string}]}
|
||||
]}.
|
||||
|
||||
{translation, "rabbit.default_policies.operator", fun(Conf) ->
|
||||
Props = rabbit_cuttlefish:aggregate_props(Conf, ["default_policies", "operator"]),
|
||||
Props = rabbit_cuttlefish:aggregate_props(
|
||||
Conf,
|
||||
["default_policies", "operator"],
|
||||
fun({["default_policies","operator",ID,"classic_queues"|T], V}) ->
|
||||
{["default_policies","operator",ID|T],V};
|
||||
(E) -> E
|
||||
end),
|
||||
Props1 = lists:map(
|
||||
fun({K, Ss}) ->
|
||||
{K,
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
-module(rabbit_cuttlefish).
|
||||
|
||||
-export([
|
||||
aggregate_props/2
|
||||
aggregate_props/2,
|
||||
aggregate_props/3
|
||||
]).
|
||||
|
||||
-type keyed_props() :: [{binary(), [{binary(), any()}]}].
|
||||
|
@ -16,13 +17,19 @@
|
|||
-spec aggregate_props([{string(), any()}], [string()]) ->
|
||||
keyed_props().
|
||||
aggregate_props(Conf, Prefix) ->
|
||||
aggregate_props(Conf, Prefix, fun(E) -> E end).
|
||||
|
||||
-spec aggregate_props([{string(), any()}], [string()], function()) ->
|
||||
keyed_props().
|
||||
aggregate_props(Conf, Prefix, KeyFun) ->
|
||||
Pattern = Prefix ++ ["$id", "$_"],
|
||||
PrefixLen = length(Prefix),
|
||||
FlatList = lists:filtermap(
|
||||
fun({K, V}) ->
|
||||
fun(E) ->
|
||||
{K, V} = KeyFun(E),
|
||||
case cuttlefish_variable:is_fuzzy_match(K, Pattern) of
|
||||
true -> {true, {lists:nthtail(PrefixLen, K), V}};
|
||||
_ -> false
|
||||
false -> false
|
||||
end
|
||||
end,
|
||||
Conf
|
||||
|
|
|
@ -123,9 +123,13 @@ ssl_options.fail_if_no_peer_cert = true",
|
|||
default_policies.operator.a.expires = 1h
|
||||
default_policies.operator.a.queue_pattern = apple
|
||||
default_policies.operator.a.vhost_pattern = banana
|
||||
default_policies.operator.a.classic_queues.ha_mode = exactly
|
||||
default_policies.operator.a.classic_queues.ha_params = 2
|
||||
",
|
||||
[{rabbit, [{default_policies, [{operator, [
|
||||
{<<"a">>, [{<<"expires">>, 3600000},
|
||||
{<<"ha-mode">>, "exactly"},
|
||||
{<<"ha-params">>, 2},
|
||||
{<<"queue-pattern">>, "apple"},
|
||||
{<<"vhost-pattern">>, "banana"}]}]}]}]}],
|
||||
[]},
|
||||
|
|
Loading…
Reference in New Issue