Skip to content

Commit

Permalink
to squash: Add types to worker_throttle.
Browse files Browse the repository at this point in the history
This breaks dialyzer on Erlang 17.
  • Loading branch information
Shayan Pooya committed Apr 17, 2014
1 parent d6ad02e commit f857bde
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions master/src/worker_throttle.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
-export([init/0, handle/1]).

-define(MAX_EVENTS_PER_SECOND, 5).

-include("common_types.hrl").

-define(MICROSECONDS_IN_SECOND, 1000000).

-opaque state() :: queue().
-opaque state() :: disco_queue(non_neg_integer()).
-type throttle() :: {ok, non_neg_integer(), state()} | {error, term()}.

-export_type([state/0]).
Expand All @@ -25,7 +28,7 @@ handle(Q) ->
throttle(Q1, queue:len(Q1))
end.

-spec throttle(queue(), non_neg_integer()) -> throttle().
-spec throttle(disco_queue(non_neg_integer()), non_neg_integer()) -> throttle().
throttle(_Q, N) when N >= ?MAX_EVENTS_PER_SECOND * 2 ->
{error, ["Worker is behaving badly: Sent ",
integer_to_list(N), " events in a second, ignoring replies."]};
Expand Down

0 comments on commit f857bde

Please sign in to comment.