summaryrefslogtreecommitdiff
path: root/src/rabbit_limiter.erl
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-15 16:37:35 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-15 16:37:35 +0100
commitf6f05a7b83e32a1d8069fff0127545dd1e8a317a (patch)
treedebf587a771838a46dc52ec3281b64771b490371 /src/rabbit_limiter.erl
parent1230ab5de31e4ea885d4706982bb3c5a5d958916 (diff)
downloadrabbitmq-server-f6f05a7b83e32a1d8069fff0127545dd1e8a317a.tar.gz
refactor
Diffstat (limited to 'src/rabbit_limiter.erl')
-rw-r--r--src/rabbit_limiter.erl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/rabbit_limiter.erl b/src/rabbit_limiter.erl
index 1104d33c..2d367707 100644
--- a/src/rabbit_limiter.erl
+++ b/src/rabbit_limiter.erl
@@ -20,13 +20,14 @@
-export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
handle_info/2, prioritise_call/3]).
--export([start_link/0, make_token/1, is_enabled/1, enable/2, disable/1]).
+-export([start_link/0, make_token/0, make_token/1, is_enabled/1, enable/2,
+ disable/1]).
-export([limit/2, can_send/3, ack/2, register/2, unregister/2]).
-export([get_limit/1, block/1, unblock/1, is_blocked/1]).
%%----------------------------------------------------------------------------
--record(token, {pid, enabled = false}).
+-record(token, {pid, enabled}).
-ifdef(use_specs).
@@ -35,6 +36,7 @@
-opaque(token() :: #token{}).
-spec(start_link/0 :: () -> rabbit_types:ok_pid_or_error()).
+-spec(make_token/0 :: () -> token()).
-spec(make_token/1 :: (undefined | pid()) -> token()).
-spec(is_enabled/1 :: (token()) -> boolean()).
-spec(enable/2 :: (token(), non_neg_integer()) -> token()).
@@ -68,7 +70,8 @@
start_link() -> gen_server2:start_link(?MODULE, [], []).
-make_token(Pid) -> #token{pid = Pid}.
+make_token() -> make_token(undefined).
+make_token(Pid) -> #token{pid = Pid, enabled = false}.
is_enabled(#token{enabled = Enabled}) -> Enabled.