summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-07-30 16:46:46 +0100
committerSimon MacMullen <simon@rabbitmq.com>2013-07-30 16:46:46 +0100
commitd32815323a0d72bbf05c6662cbe5d96612dc9a68 (patch)
tree6356589646e995c8308cfec9d253208512a2929e
parente127bf47ca80bfbc1b5f098920bf7c7deb66f48d (diff)
downloadrabbitmq-server-d32815323a0d72bbf05c6662cbe5d96612dc9a68.tar.gz
Pick an apply-to value heuristically.
-rw-r--r--src/rabbit_upgrade_functions.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rabbit_upgrade_functions.erl b/src/rabbit_upgrade_functions.erl
index d76002dd..76bfe28a 100644
--- a/src/rabbit_upgrade_functions.erl
+++ b/src/rabbit_upgrade_functions.erl
@@ -305,12 +305,22 @@ policy_apply_to() ->
transform(
rabbit_runtime_parameters,
fun ({runtime_parameters, Key = {_VHost, <<"policy">>, _Name}, Value}) ->
- {runtime_parameters, Key, [{<<"apply-to">>, <<"both">>} | Value]};
+ ApplyTo = apply_to(proplists:get_value(<<"definition">>, Value)),
+ {runtime_parameters, Key, [{<<"apply-to">>, ApplyTo} | Value]};
({runtime_parameters, Key, Value}) ->
{runtime_parameters, Key, Value}
end,
[key, value]).
+apply_to(Def) ->
+ case [proplists:get_value(K, Def) ||
+ K <- [<<"federation-upstream-set">>, <<"ha-mode">>]] of
+ [undefined, undefined] -> <<"both">>;
+ [_, undefined] -> <<"exchanges">>;
+ [undefined, _] -> <<"queues">>;
+ [_, _] -> <<"both">>
+ end.
+
%%--------------------------------------------------------------------
transform(TableName, Fun, FieldList) ->