summaryrefslogtreecommitdiff
path: root/src/rabbit_limiter.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-01-29 16:06:46 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-01-29 16:06:46 +0000
commit39ac6385e1e3b0d215349ec3dc3476eda9432c7d (patch)
tree75623f6cd0c78ec587b95c4c156ee4d69a11f226 /src/rabbit_limiter.erl
parent5727b84d107c4116169d3798855c015fe531630e (diff)
downloadrabbitmq-server-39ac6385e1e3b0d215349ec3dc3476eda9432c7d.tar.gz
rabbit_limiter:initial_credit/6.
Diffstat (limited to 'src/rabbit_limiter.erl')
-rw-r--r--src/rabbit_limiter.erl22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/rabbit_limiter.erl b/src/rabbit_limiter.erl
index 4796fc0e..865c4677 100644
--- a/src/rabbit_limiter.erl
+++ b/src/rabbit_limiter.erl
@@ -24,7 +24,7 @@
disable/1]).
-export([limit/2, can_send/6, ack/2, register/2, unregister/2]).
-export([get_limit/1, block/1, unblock/1, is_blocked/1]).
--export([credit/7, forget_consumer/2, copy_queue_state/2]).
+-export([initial_credit/6, credit/6, forget_consumer/2, copy_queue_state/2]).
-import(rabbit_misc, [serial_add/2, serial_diff/2]).
@@ -55,8 +55,11 @@
-spec(block/1 :: (token()) -> 'ok').
-spec(unblock/1 :: (token()) -> 'ok' | {'disabled', token()}).
-spec(is_blocked/1 :: (token()) -> boolean()).
--spec(credit/7 :: (token(), pid(), rabbit_types:ctag(),
- non_neg_integer(), boolean(), boolean(), non_neg_integer())
+-spec(initial_credit/6 :: (token(), pid(), rabbit_types:ctag(),
+ non_neg_integer(), boolean(), non_neg_integer())
+ -> token()).
+-spec(credit/6 :: (token(), pid(), rabbit_types:ctag(),
+ non_neg_integer(), boolean(), non_neg_integer())
-> {[rabbit_types:ctag()], token()}).
-spec(forget_consumer/2 :: (token(), rabbit_types:ctag()) -> token()).
-spec(copy_queue_state/2 :: (token(), token()) -> token()).
@@ -147,14 +150,17 @@ unblock(Limiter) ->
is_blocked(Limiter) ->
maybe_call(Limiter, is_blocked, false).
+initial_credit(Limiter = #token{q_state = Credits},
+ ChPid, CTag, Credit, Drain, Len) ->
+ {[], Credits2} = update_credit(
+ CTag, Len, ChPid, Credit, Drain, Credits),
+ Limiter#token{q_state = Credits2}.
+
credit(Limiter = #token{q_state = Credits},
- ChPid, CTag, Credit, Drain, Reply, Len) ->
+ ChPid, CTag, Credit, Drain, Len) ->
{Unblock, Credits2} = update_credit(
CTag, Len, ChPid, Credit, Drain, Credits),
- case Reply of
- true -> rabbit_channel:send_credit_reply(ChPid, Len);
- false -> ok
- end,
+ rabbit_channel:send_credit_reply(ChPid, Len),
{Unblock, Limiter#token{q_state = Credits2}}.
forget_consumer(Limiter = #token{q_state = Credits}, CTag) ->