Skip to content

Commit 54c9b85

Browse files
Make policy validation aware of the max-priority argument
References #1590. [#157380396]
1 parent 117eb9b commit 54c9b85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rabbit_policies.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ register() ->
4141
{policy_validator, <<"expires">>},
4242
{policy_validator, <<"max-length">>},
4343
{policy_validator, <<"max-length-bytes">>},
44+
{policy_validator, <<"max-priority">>},
4445
{policy_validator, <<"queue-mode">>},
4546
{policy_validator, <<"overflow">>},
4647
{operator_policy_validator, <<"expires">>},
@@ -100,6 +101,12 @@ validate_policy0(<<"max-length-bytes">>, Value)
100101
validate_policy0(<<"max-length-bytes">>, Value) ->
101102
{error, "~p is not a valid maximum length in bytes", [Value]};
102103

104+
validate_policy0(<<"max-priority">>, Value)
105+
when is_integer(Value), Value >= 0, Value =< 255 ->
106+
ok;
107+
validate_policy0(<<"max-priority">>, Value) ->
108+
{error, "~p is not a valid max priority (must be an integer in the 1-255 range)", [Value]};
109+
103110
validate_policy0(<<"queue-mode">>, <<"default">>) ->
104111
ok;
105112
validate_policy0(<<"queue-mode">>, <<"lazy">>) ->
@@ -117,4 +124,3 @@ merge_policy_value(<<"message-ttl">>, Val, OpVal) -> min(Val, OpVal);
117124
merge_policy_value(<<"max-length">>, Val, OpVal) -> min(Val, OpVal);
118125
merge_policy_value(<<"max-length-bytes">>, Val, OpVal) -> min(Val, OpVal);
119126
merge_policy_value(<<"expires">>, Val, OpVal) -> min(Val, OpVal).
120-

0 commit comments

Comments
 (0)