Skip to content

Commit

Permalink
Make credit flow state transition interval 1s instead of 5s
Browse files Browse the repository at this point in the history
Management UI and HTTP API currently report connections and channels
as in flow if they've been in flow for the last 5 seconds. That
can confuse the user with inter-node flow control, making them
believe the flow is permanent (it is not: the actual state
toggles many times a second).

This reduces the interval to 1s, which seems more reasonable and
accurate (in a way).

Fixes #138.
  • Loading branch information
michaelklishin authored and dumbbell committed May 7, 2015
1 parent 18fcb1a commit 7710829
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/credit_flow.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
put(Key, Expr)
end).

%% If current process was blocked by credit flow in the last
%% STATE_CHANGE_INTERVAL milliseconds, state/0 will report it as "in
%% flow".
-define(STATE_CHANGE_INTERVAL, 1000000).

%%----------------------------------------------------------------------------

%% There are two "flows" here; of messages and of credit, going in
Expand Down Expand Up @@ -117,7 +122,7 @@ state() -> case blocked() of
false -> case get(credit_blocked_at) of
undefined -> running;
B -> Diff = timer:now_diff(erlang:now(), B),
case Diff < 5000000 of
case Diff < ?STATE_CHANGE_INTERVAL of
true -> flow;
false -> running
end
Expand Down

0 comments on commit 7710829

Please sign in to comment.