summaryrefslogtreecommitdiff
path: root/src/rabbit_mirror_queue_misc.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-10-16 16:13:26 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-10-16 16:13:26 +0100
commit5eb37c01f3d3cc02d174e36b75a91d754029bd62 (patch)
tree33620353f39592efa4a572bcac66e64de49cb5db /src/rabbit_mirror_queue_misc.erl
parentad47942380b78d676568106e5b3bc5a462951c01 (diff)
downloadrabbitmq-server-5eb37c01f3d3cc02d174e36b75a91d754029bd62.tar.gz
Refactor
Diffstat (limited to 'src/rabbit_mirror_queue_misc.erl')
-rw-r--r--src/rabbit_mirror_queue_misc.erl44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/rabbit_mirror_queue_misc.erl b/src/rabbit_mirror_queue_misc.erl
index 6976dbbc..8950051e 100644
--- a/src/rabbit_mirror_queue_misc.erl
+++ b/src/rabbit_mirror_queue_misc.erl
@@ -333,28 +333,28 @@ update_mirrors0(OldQ = #amqqueue{name = QName},
%%----------------------------------------------------------------------------
-validate_policy(TagList) ->
- Mode = proplists:get_all_values(<<"ha-mode">>, TagList),
- Params = proplists:get_all_values(<<"ha-params">>, TagList),
- case Mode of
- [<<"all">>] ->
- ok;
- [<<"nodes">>] ->
- validate_params(lists:append(Params),
- fun erlang:is_binary/1,
- "~p has invalid node names when ha-mode=nodes",
- fun (N) -> N > 0 end,
- "at least one node expected when ha-mode=nodes");
- [<<"exactly">>] ->
- validate_params(Params,
- fun (N) -> is_integer(N) andalso N > 0 end,
- "~p must be a positive integer",
- fun (N) -> N == 1 end,
- "ha-params must be supplied with one number "
- "when ha-mode=exactly");
- [Other] ->
- {error, "~p is not a valid ha-mode value", [Other]}
- end.
+validate_policy(KeyList) ->
+ validate_policy(
+ proplists:get_value(<<"ha-mode">>, KeyList),
+ proplists:get_value(<<"ha-params">>, KeyList)).
+
+validate_policy(<<"all">>, _Params) ->
+ ok;
+validate_policy(<<"nodes">>, Params) ->
+ validate_params(lists:append(Params),
+ fun erlang:is_binary/1,
+ "~p has invalid node names when ha-mode=nodes",
+ fun (N) -> N > 0 end,
+ "at least one node expected when ha-mode=nodes");
+validate_policy(<<"exactly">>, Params) ->
+ validate_params(Params,
+ fun (N) -> is_integer(N) andalso N > 0 end,
+ "~p must be a positive integer",
+ fun (N) -> N == 1 end,
+ "ha-params must be supplied with one number "
+ "when ha-mode=exactly");
+validate_policy(Mode, _Params) ->
+ {error, "~p is not a valid ha-mode value", [Mode]}.
validate_params(Params, FilterPred, FilterMsg, SizePred, SizeMsg)
when is_list(Params) ->