diff options
author | Emile Joubert <emile@rabbitmq.com> | 2012-09-06 17:51:47 +0100 |
---|---|---|
committer | Emile Joubert <emile@rabbitmq.com> | 2012-09-06 17:51:47 +0100 |
commit | f6608db0967558512db0259884448f39d43fd6e1 (patch) | |
tree | 8113b383a510f7348c006ebe6f164854714fe968 /src/rabbit_policy.erl | |
parent | d3cf2296e2247c15226189b00646a6b8784b7c3b (diff) | |
download | rabbitmq-server-f6608db0967558512db0259884448f39d43fd6e1.tar.gz |
Permit absent policy priority
Diffstat (limited to 'src/rabbit_policy.erl')
-rw-r--r-- | src/rabbit_policy.erl | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl index 3400a7d5..6c36df87 100644 --- a/src/rabbit_policy.erl +++ b/src/rabbit_policy.erl @@ -82,7 +82,7 @@ notify_clear(VHost, <<"policy">>, _Name) -> list(VHost) -> lists:sort(fun sort_pred/2, - [[{<<"name">>, pget(key, P)} | pget(value, P)] + [[{<<"name">>, pget(key, P)} | defaults(pget(value, P))] || P <- rabbit_runtime_parameters:list(VHost, <<"policy">>)]). update_policies(VHost) -> @@ -157,7 +157,16 @@ sort_pred(A, B) -> %%---------------------------------------------------------------------------- +defaults(Props) -> + Def = [{Key, Def} || {Key, _Fun, {optional, Def}} <- policy_validation()], + lists:foldl(fun ({Key, Default}, Props1) -> + case pget(Key, Props1) of + undefined -> [{Key, Default} | Props1]; + _ -> Props1 + end + end, Props, Def). + policy_validation() -> - [{<<"priority">>, fun rabbit_parameter_validation:number/2, mandatory}, + [{<<"priority">>, fun rabbit_parameter_validation:number/2, {optional, 0}}, {<<"pattern">>, fun rabbit_parameter_validation:regex/2, mandatory}, - {<<"policy">>, fun rabbit_parameter_validation:list/2, mandatory}]. + {<<"policy">>, fun rabbit_parameter_validation:list/2, mandatory}]. |