diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2012-10-16 16:16:04 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2012-10-16 16:16:04 +0100 |
| commit | 0f196e9c16b585a63a06933ae98dea26f6ef7c7a (patch) | |
| tree | e63e11b55395155e8e1a256fb3057ba954a08097 | |
| parent | 4aa14e3ec802fe89a661f05a55380e7d99043f0e (diff) | |
| download | rabbitmq-server-git-0f196e9c16b585a63a06933ae98dea26f6ef7c7a.tar.gz | |
We call it "set" not "add" everywhere else.
| -rw-r--r-- | src/rabbit_control_main.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_policy.erl | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 3f3a0b8b51..c5ded0197d 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -470,7 +470,7 @@ action(set_policy, Node, [Key, Pattern, Defn | Prio], Opts, Inform) end, VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), Inform(InformMsg, [Key, Pattern, Defn] ++ Prio), - rpc_call(Node, rabbit_policy, parse_add, + rpc_call(Node, rabbit_policy, parse_set, [VHostArg, list_to_binary(Key), Pattern, Defn, Prio1]); action(clear_policy, Node, [Key], Opts, Inform) -> diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl index c938d1be8f..4039607abe 100644 --- a/src/rabbit_policy.erl +++ b/src/rabbit_policy.erl @@ -27,7 +27,7 @@ -export([register/0]). -export([name/1, get/2, set/1]). -export([validate/4, validate_clear/3, notify/4, notify_clear/3]). --export([parse_add/5, add/5, delete/2, lookup/2, list/0, list/1, +-export([parse_set/5, set/5, delete/2, lookup/2, list/0, list/1, list_formatted/1, info_keys/0]). -define(TABLE, rabbit_runtime_parameters). @@ -69,34 +69,34 @@ get0(Name, List) -> case pget(definition, List) of %%---------------------------------------------------------------------------- -parse_add(VHost, Key, Pattern, Definition, undefined) -> - parse_add_policy0(VHost, Key, Pattern, Definition, []); -parse_add(VHost, Key, Pattern, Definition, Priority) -> +parse_set(VHost, Key, Pattern, Definition, undefined) -> + parse_set0(VHost, Key, Pattern, Definition, []); +parse_set(VHost, Key, Pattern, Definition, Priority) -> try list_to_integer(Priority) of - Num -> parse_add_policy0(VHost, Key, Pattern, Definition, + Num -> parse_set0(VHost, Key, Pattern, Definition, [{<<"priority">>, Num}]) catch error:badarg -> {error, "~p priority must be a number", [Priority]} end. -parse_add_policy0(VHost, Key, Pattern, Defn, Priority) -> +parse_set0(VHost, Key, Pattern, Defn, Priority) -> case rabbit_misc:json_decode(Defn) of {ok, JSON} -> - add0(VHost, Key, [{<<"pattern">>, list_to_binary(Pattern)}, + set0(VHost, Key, [{<<"pattern">>, list_to_binary(Pattern)}, {<<"policy">>, rabbit_misc:json_to_term(JSON)}] ++ Priority); error -> {error_string, "JSON decoding error"} end. -add(VHost, Key, Pattern, Definition, Priority) -> +set(VHost, Key, Pattern, Definition, Priority) -> PolicyProps = [{<<"pattern">>, Pattern}, {<<"policy">>, Definition}], - add0(VHost, Key, case Priority of + set0(VHost, Key, case Priority of undefined -> []; _ -> [{<<"priority">>, Priority}] end ++ PolicyProps). -add0(VHost, Key, Term) -> +set0(VHost, Key, Term) -> rabbit_runtime_parameters:set_any(VHost, <<"policy">>, Key, Term). delete(VHost, Key) -> |
