From 7710829844feecee3acb102f50e7202d3aed768e Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 7 May 2015 15:28:18 +0300 Subject: [PATCH] Make credit flow state transition interval 1s instead of 5s 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. --- src/credit_flow.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/credit_flow.erl b/src/credit_flow.erl index 893206214564..ab54b823356f 100644 --- a/src/credit_flow.erl +++ b/src/credit_flow.erl @@ -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 @@ -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