summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-02-18 14:37:00 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-02-18 14:37:00 +0000
commit0ecd80bdd7bdc211f775ac409ebe424ea3fa90a6 (patch)
treeb49444b4da340b0c7b570b368a21b41953bedda4
parentf8331aa6edeabc82931aa016d926d57427d71d1c (diff)
downloadrabbitmq-server-0ecd80bdd7bdc211f775ac409ebe424ea3fa90a6.tar.gz
Remove rabbit_runtime_parameter:validate_clear/3, and instead just validate that the parameter exists.bug25456
-rw-r--r--src/rabbit_policy.erl5
-rw-r--r--src/rabbit_runtime_parameter.erl3
-rw-r--r--src/rabbit_runtime_parameters.erl22
-rw-r--r--src/rabbit_runtime_parameters_test.erl6
-rw-r--r--src/rabbit_tests.erl4
5 files changed, 13 insertions, 27 deletions
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index e712078b..7398cd2d 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -26,7 +26,7 @@
-export([register/0]).
-export([name/1, get/2, set/1]).
--export([validate/4, validate_clear/3, notify/4, notify_clear/3]).
+-export([validate/4, notify/4, notify_clear/3]).
-export([parse_set/5, set/5, delete/2, lookup/2, list/0, list/1,
list_formatted/1, info_keys/0]).
@@ -146,9 +146,6 @@ validate(_VHost, <<"policy">>, Name, Term) ->
rabbit_parameter_validation:proplist(
Name, policy_validation(), Term).
-validate_clear(_VHost, <<"policy">>, _Name) ->
- ok.
-
notify(VHost, <<"policy">>, _Name, _Term) ->
update_policies(VHost).
diff --git a/src/rabbit_runtime_parameter.erl b/src/rabbit_runtime_parameter.erl
index 8a237105..6b62c974 100644
--- a/src/rabbit_runtime_parameter.erl
+++ b/src/rabbit_runtime_parameter.erl
@@ -23,8 +23,6 @@
-callback validate(rabbit_types:vhost(), binary(), binary(),
term()) -> validate_results().
--callback validate_clear(rabbit_types:vhost(), binary(),
- binary()) -> validate_results().
-callback notify(rabbit_types:vhost(), binary(), binary(), term()) -> 'ok'.
-callback notify_clear(rabbit_types:vhost(), binary(), binary()) -> 'ok'.
@@ -35,7 +33,6 @@
behaviour_info(callbacks) ->
[
{validate, 4},
- {validate_clear, 3},
{notify, 4},
{notify_clear, 3}
];
diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl
index 2615372c..b1100b65 100644
--- a/src/rabbit_runtime_parameters.erl
+++ b/src/rabbit_runtime_parameters.erl
@@ -120,21 +120,13 @@ clear(VHost, Component, Name) ->
clear_any(VHost, Component, Name).
clear_any(VHost, Component, Name) ->
- case clear_any0(VHost, Component, Name) of
- ok -> ok;
- {errors, L} -> format_error(L)
- end.
-
-clear_any0(VHost, Component, Name) ->
- case lookup_component(Component) of
- {ok, Mod} -> case flatten_errors(
- Mod:validate_clear(VHost, Component, Name)) of
- ok -> mnesia_clear(VHost, Component, Name),
- Mod:notify_clear(VHost, Component, Name),
- ok;
- E -> E
- end;
- E -> E
+ case lookup(VHost, Component, Name) of
+ not_found -> {error_string, "Parameter does not exist"};
+ _ -> mnesia_clear(VHost, Component, Name),
+ case lookup_component(Component) of
+ {ok, Mod} -> Mod:notify_clear(VHost, Component, Name);
+ _ -> ok
+ end
end.
mnesia_clear(VHost, Component, Name) ->
diff --git a/src/rabbit_runtime_parameters_test.erl b/src/rabbit_runtime_parameters_test.erl
index c27f1b4a..05c1dbc1 100644
--- a/src/rabbit_runtime_parameters_test.erl
+++ b/src/rabbit_runtime_parameters_test.erl
@@ -18,7 +18,7 @@
-behaviour(rabbit_runtime_parameter).
-behaviour(rabbit_policy_validator).
--export([validate/4, validate_clear/3, notify/4, notify_clear/3]).
+-export([validate/4, notify/4, notify_clear/3]).
-export([register/0, unregister/0]).
-export([validate_policy/1]).
-export([register_policy_validator/0, unregister_policy_validator/0]).
@@ -35,10 +35,6 @@ validate(_, <<"test">>, <<"good">>, _Term) -> ok;
validate(_, <<"test">>, <<"maybe">>, <<"good">>) -> ok;
validate(_, <<"test">>, _, _) -> {error, "meh", []}.
-validate_clear(_, <<"test">>, <<"good">>) -> ok;
-validate_clear(_, <<"test">>, <<"maybe">>) -> ok;
-validate_clear(_, <<"test">>, _) -> {error, "meh", []}.
-
notify(_, _, _, _) -> ok.
notify_clear(_, _, _) -> ok.
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 87946888..60ee26e5 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1061,7 +1061,11 @@ test_runtime_parameters() ->
ok = control_action(clear_parameter, ["test", "maybe"]),
{error_string, _} =
control_action(clear_parameter, ["test", "neverexisted"]),
+
+ %% We can delete for a component that no longer exists
+ Good(["test", "good", "\"ignore\""]),
rabbit_runtime_parameters_test:unregister(),
+ ok = control_action(clear_parameter, ["test", "good"]),
passed.
test_policy_validation() ->