Module SimpleHttpServer
Class ServerExchangeThrottler
java.lang.Object
dev.katsute.simplehttpserver.handler.throttler.ServerExchangeThrottler
A throttler that limits the amount of simultaneous connections based on individual and total exchanges.
- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- Katsute
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a throttler with no total connection limit.ServerExchangeThrottler
(int maxConnections) Creates a throttler with a limit on max total connections. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canIgnoreConnectionLimit
(SimpleHttpExchange exchange) If true, an exchange does not contribute to the total server connections and can bypass the maximum limit.int
getMaxConnections
(SimpleHttpExchange exchange) Returns the maximum number of connections allowed for an exchange.final int
Returns the maximum amount of server connections that is allowed.final void
setMaxServerConnections
(int connections) Sets the maximum amount of server connections that is allowed.toString()
-
Constructor Details
-
ServerExchangeThrottler
public ServerExchangeThrottler()Creates a throttler with no total connection limit.- Since:
- 5.0.0
-
ServerExchangeThrottler
public ServerExchangeThrottler(int maxConnections) Creates a throttler with a limit on max total connections.- Parameters:
maxConnections
- max total connections- Since:
- 5.0.0
-
-
Method Details
-
getMaxConnections
Returns the maximum number of connections allowed for an exchange. Return-1
for unlimited connections.- Parameters:
exchange
- exchange- Returns:
- maximum connections
- See Also:
-
canIgnoreConnectionLimit
If true, an exchange does not contribute to the total server connections and can bypass the maximum limit. Still limited bygetMaxConnections(SimpleHttpExchange)
.- Parameters:
exchange
- exchange- Returns:
- if exchange can bypass limit
- Since:
- 5.0.0
- See Also:
-
setMaxServerConnections
public final void setMaxServerConnections(int connections) Sets the maximum amount of server connections that is allowed.- Parameters:
connections
- max connections- Since:
- 5.0.0
- See Also:
-
getMaxServerConnections
public final int getMaxServerConnections()Returns the maximum amount of server connections that is allowed.- Returns:
- max connections
- Since:
- 5.0.0
- See Also:
-
toString
-