Skip to content

Commit fc2622d

Browse files
Merge pull request #198 from Unknovvn/Conversion-to-float-numbers-added-in-try_convert_to_int
Conversion to float numbers implemented in try_convert_to_int
2 parents e0c23ec + 796ce3e commit fc2622d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rabbit_delayed_message_utils.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
-define(STRING_ARG_TYPES, [longstr, shortstr]).
1818

19+
-define(FLOAT_ARG_TYPES, [decimal, double, float]).
20+
1921
-import(rabbit_misc, [table_lookup/2, set_table_value/4]).
2022

2123
get_delay(Delivery) ->
@@ -91,7 +93,11 @@ get_headers(#'P_basic'{headers = H}) ->
9193
try_convert_to_int(Type, Delay) ->
9294
case lists:member(Type, ?STRING_ARG_TYPES) of
9395
true -> {ok, binary_to_integer(Delay)};
94-
false -> {error, {unacceptable_type, Type}}
96+
false ->
97+
case lists:member(Type, ?FLOAT_ARG_TYPES) of
98+
true -> {ok, trunc(Delay)};
99+
false -> {error, {unacceptable_type, Type}}
100+
end.
95101
end.
96102

97103
%% adapted from rabbit_amqqueue.erl

0 commit comments

Comments
 (0)