aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-12-24 16:16:00 +0100
committerLoïc Hoguin <[email protected]>2012-12-24 16:16:00 +0100
commit201a0cb5e421e24ffcce0d6315b2190d103bcb06 (patch)
tree796f28b22ab6b2315717ede3eb391f2a71c6cfe1 /src/ranch.erl
parent9993923c40b96ab07752ec36692dc09c4c7648e9 (diff)
downloadranch-201a0cb5e421e24ffcce0d6315b2190d103bcb06.tar.gz
ranch-201a0cb5e421e24ffcce0d6315b2190d103bcb06.tar.bz2
ranch-201a0cb5e421e24ffcce0d6315b2190d103bcb06.zip
Improve max_connections type
It is non_neg_integer() | infinity. Introduce the type `ranch:max_conns/0` for easier manipulation.
Diffstat (limited to 'src/ranch.erl')
-rw-r--r--src/ranch.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index c582efa..752819e 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -28,6 +28,9 @@
-export([set_option_default/3]).
-export([require/1]).
+-type max_conns() :: non_neg_integer() | infinity.
+-export_type([max_conns/0]).
+
%% @doc Start a listener for the given transport and protocol.
%%
%% A listener is effectively a pool of <em>NbAcceptors</em> acceptors.
@@ -124,14 +127,14 @@ get_port(Ref) ->
Port.
%% @doc Return the max number of connections allowed concurrently.
--spec get_max_connections(any()) -> non_neg_integer().
+-spec get_max_connections(any()) -> max_conns().
get_max_connections(Ref) ->
ListenerPid = ranch_server:lookup_listener(Ref),
{ok, MaxConnections} = ranch_listener:get_max_connections(ListenerPid),
MaxConnections.
%% @doc Set the max number of connections allowed concurrently.
--spec set_max_connections(any(), non_neg_integer()) -> ok.
+-spec set_max_connections(any(), max_conns()) -> ok.
set_max_connections(Ref, MaxConnections) ->
ListenerPid = ranch_server:lookup_listener(Ref),
ok = ranch_listener:set_max_connections(ListenerPid, MaxConnections).