Add ha-sync-mode as an operator policy
This commit is contained in:
parent
167246f5d9
commit
367b1f0a6d
|
@ -776,6 +776,10 @@ end}.
|
|||
{datatype, [integer, {list, string}]}
|
||||
]}.
|
||||
|
||||
{mapping, "default_policies.operator.$id.classic_queues.ha_sync_mode", "rabbit.default_policies.operator", [
|
||||
{datatype, string}
|
||||
]}.
|
||||
|
||||
{translation, "rabbit.default_policies.operator", fun(Conf) ->
|
||||
Props = rabbit_cuttlefish:aggregate_props(
|
||||
Conf,
|
||||
|
|
|
@ -54,10 +54,14 @@
|
|||
[operator_policy_validator, <<"ha-mode">>, ?MODULE]}},
|
||||
{mfa, {rabbit_registry, register,
|
||||
[operator_policy_validator, <<"ha-params">>, ?MODULE]}},
|
||||
{mfa, {rabbit_registry, register,
|
||||
[operator_policy_validator, <<"ha-sync-mode">>, ?MODULE]}},
|
||||
{mfa, {rabbit_registry, register,
|
||||
[policy_merge_strategy, <<"ha-mode">>, ?MODULE]}},
|
||||
{mfa, {rabbit_registry, register,
|
||||
[policy_merge_strategy, <<"ha-params">>, ?MODULE]}},
|
||||
{mfa, {rabbit_registry, register,
|
||||
[policy_merge_strategy, <<"ha-sync-mode">>, ?MODULE]}},
|
||||
{requires, rabbit_registry},
|
||||
{enables, recovery}]}).
|
||||
|
||||
|
@ -870,6 +874,8 @@ merge_policy_value(<<"ha-mode">>, <<"exactly">> = Val, _OpVal) ->
|
|||
Val;
|
||||
merge_policy_value(<<"ha-mode">>, _Val, <<"exactly">> = OpVal) ->
|
||||
OpVal;
|
||||
merge_policy_value(<<"ha-sync-mode">>, _Val, OpVal) ->
|
||||
OpVal;
|
||||
%% Both values are integers, both are ha-mode 'exactly'
|
||||
merge_policy_value(<<"ha-params">>, Val, OpVal) when is_integer(Val)
|
||||
andalso
|
||||
|
|
|
@ -142,11 +142,14 @@ ssl_options.fail_if_no_peer_cert = true",
|
|||
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
|
||||
default_policies.operator.a.classic_queues.ha_sync_mode = automatic
|
||||
|
||||
",
|
||||
[{rabbit, [{default_policies, [{operator, [
|
||||
{<<"a">>, [{<<"expires">>, 3600000},
|
||||
{<<"ha_mode">>, "exactly"},
|
||||
{<<"ha_params">>, 2},
|
||||
{<<"ha_sync_mode">>, "automatic"},
|
||||
{<<"queue_pattern">>, "apple"},
|
||||
{<<"vhost_pattern">>, "banana"}]}]}]}]}],
|
||||
[]},
|
||||
|
|
|
@ -168,12 +168,13 @@ target_count_policy(Config) ->
|
|||
{<<"ha-params">>, BNodes}],
|
||||
NodesPolicyOne = [{<<"ha-mode">>, <<"nodes">>},
|
||||
{<<"ha-params">>, [hd(BNodes)]}],
|
||||
SyncModePolicyAuto = [{<<"ha-mode">>, <<"all">>}, {<<"ha-sync-mode">>, <<"automatic">>}],
|
||||
SyncModePolicyMan = [{<<"ha-mode">>, <<"all">>}, {<<"ha-sync-mode">>, <<"manual">>}],
|
||||
|
||||
%% ALL has precedence
|
||||
Opts = #{config => Config,
|
||||
server => Server,
|
||||
qname => QName},
|
||||
|
||||
verify_policies(AllPolicy, ExactlyPolicyTwo, [{<<"ha-mode">>, <<"all">>}], Opts),
|
||||
|
||||
verify_policies(ExactlyPolicyTwo, AllPolicy, [{<<"ha-mode">>, <<"all">>}], Opts),
|
||||
|
@ -182,6 +183,10 @@ target_count_policy(Config) ->
|
|||
|
||||
verify_policies(NodesPolicyAll, AllPolicy, [{<<"ha-mode">>, <<"all">>}], Opts),
|
||||
|
||||
%% %% Sync mode OperPolicy has precedence
|
||||
verify_policies(SyncModePolicyMan, SyncModePolicyAuto, [{<<"ha-sync-mode">>, <<"automatic">>}], Opts),
|
||||
verify_policies(SyncModePolicyAuto, SyncModePolicyMan, [{<<"ha-sync-mode">>, <<"manual">>}], Opts),
|
||||
|
||||
%% exactly has precedence over nodes
|
||||
verify_policies(ExactlyPolicyTwo, NodesPolicyAll,[{<<"ha-mode">>, <<"exactly">>}, {<<"ha-params">>, 2}], Opts),
|
||||
|
||||
|
|
Loading…
Reference in New Issue