summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2016-11-17 21:55:32 +0300
committerGitHub <noreply@github.com>2016-11-17 21:55:32 +0300
commitfd69c99db2ee7b6f4f0c615f2fda3ff6ac32743f (patch)
tree9e41c151658e6621c9d1746b19b408e7509c38e6
parentc53ac3f20bc0b58b08ccec428902b1d6de4f3e75 (diff)
parent5df678db80f73446987ad3db8738334efde7162b (diff)
downloadrabbitmq-server-git-fd69c99db2ee7b6f4f0c615f2fda3ff6ac32743f.tar.gz
Merge pull request #1031 from rabbitmq/rabbitmq-server-1030
Use binaries to define policies
-rw-r--r--src/rabbit_control_main.erl4
-rw-r--r--src/rabbit_policy.erl7
2 files changed, 5 insertions, 6 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index 1619f25494..babaf4fd4e 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -537,7 +537,7 @@ action(set_policy, Node, [Key, Pattern, Defn], Opts, Inform) ->
Inform(Msg, [Key, Pattern, Defn, PriorityArg]),
Res = rpc_call(
Node, rabbit_policy, parse_set,
- [VHostArg, list_to_binary(Key), Pattern, Defn, PriorityArg, ApplyToArg]),
+ [VHostArg, list_to_binary(Key), list_to_binary(Pattern), list_to_binary(Defn), list_to_binary(PriorityArg), ApplyToArg]),
case Res of
{error, Format, Args} when is_list(Format) andalso is_list(Args) ->
{error_string, rabbit_misc:format(Format, Args)};
@@ -558,7 +558,7 @@ action(set_operator_policy, Node, [Key, Pattern, Defn], Opts, Inform) ->
Inform(Msg, [Key, Pattern, Defn, PriorityArg]),
Res = rpc_call(
Node, rabbit_policy, parse_set_op,
- [VHostArg, list_to_binary(Key), Pattern, Defn, PriorityArg, ApplyToArg]),
+ [VHostArg, list_to_binary(Key), list_to_binary(Pattern), list_to_binary(Defn), list_to_binary(PriorityArg), ApplyToArg]),
case Res of
{error, Format, Args} when is_list(Format) andalso is_list(Args) ->
{error_string, rabbit_misc:format(Format, Args)};
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index cfbf116cbd..437842b8dd 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -205,18 +205,17 @@ parse_set(VHost, Name, Pattern, Definition, Priority, ApplyTo) ->
parse_set(<<"policy">>, VHost, Name, Pattern, Definition, Priority, ApplyTo).
parse_set(Type, VHost, Name, Pattern, Definition, Priority, ApplyTo) ->
- try list_to_integer(Priority) of
+ try rabbit_data_coercion:to_integer(Priority) of
Num -> parse_set0(Type, VHost, Name, Pattern, Definition, Num, ApplyTo)
catch
error:badarg -> {error, "~p priority must be a number", [Priority]}
end.
parse_set0(Type, VHost, Name, Pattern, Defn, Priority, ApplyTo) ->
- Definition = rabbit_data_coercion:to_binary(Defn),
- case rabbit_json:try_decode(Definition) of
+ case rabbit_json:try_decode(Defn) of
{ok, Term} ->
set0(Type, VHost, Name,
- [{<<"pattern">>, list_to_binary(Pattern)},
+ [{<<"pattern">>, Pattern},
{<<"definition">>, maps:to_list(Term)},
{<<"priority">>, Priority},
{<<"apply-to">>, ApplyTo}]);