public interface ServerConfig extends ConfigData
This object represents the basic information needed to bootstrap the server (e.g. getPort()
),
but also provides access to any externalised config objects to be used by the application via ConfigData.get(String, Class)
(see also: getRequiredConfig()
).
A server config object is-a ConfigData
object.
Server config objects are programmatically built via a ServerConfigBuilder
, which can be obtained via the static methods builder()
} and embedded()
.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_CHUNK_SIZE
The default maximum chunk size to use when reading request/response bodies.
|
static int |
DEFAULT_MAX_CONTENT_LENGTH
The default max content length.
|
static int |
DEFAULT_PORT
The default port for Ratpack applications, 5050.
|
static int |
DEFAULT_THREADS
The default number of threads an application should use.
|
static TypeToken<ServerConfig> |
TYPE
A type token for this type.
|
Modifier and Type | Method and Description |
---|---|
static ServerConfigBuilder |
builder() |
static ServerConfigBuilder |
embedded()
Creates a builder configured for development mode and an ephemeral port.
|
InetAddress |
getAddress()
The address of the interface that the application should bind to.
|
FileSystemBinding |
getBaseDir()
The base dir of the application, which is also the initial
FileSystemBinding . |
Optional<Integer> |
getConnectTimeoutMillis()
The connect timeout of the channel.
|
int |
getMaxChunkSize()
The maximum chunk size to use when reading request (server) or response (client) bodies.
|
int |
getMaxContentLength()
The max content length to use for the HttpObjectAggregator.
|
Optional<Integer> |
getMaxMessagesPerRead()
The maximum number of messages to read per read loop.
|
int |
getPort()
The port that the application should listen to requests on.
|
URI |
getPublicAddress()
The public address of the site used for redirects.
|
Optional<Integer> |
getReceiveBufferSize()
The StandardSocketOptions.SO_RCVBUF option.
|
ImmutableSet<ConfigObject<?>> |
getRequiredConfig()
The config objects that were declared as required when this server config was built.
|
SSLContext |
getSslContext()
The SSL context to use if the application will serve content over HTTPS.
|
int |
getThreads()
The number of threads for handling application requests.
|
Optional<Integer> |
getWriteSpinCount()
The maximum loop count for a write operation until WritableByteChannel.write(ByteBuffer) returns a non-zero value.
|
boolean |
isDevelopment()
Whether or not the server is in "development" mode.
|
boolean |
isHasBaseDir()
Whether or not the base dir of the application has been set.
|
boolean |
isRequireClientSslAuth()
Whether or not the server needs client SSL authentication
SSLEngine.setNeedClientAuth(boolean) . |
static ServerConfig |
of(Action<? super ServerConfigBuilder> action) |
builder, get, get, getAsConfigObject, getRootNode, of, of
static final TypeToken<ServerConfig> TYPE
static final int DEFAULT_PORT
static final int DEFAULT_MAX_CONTENT_LENGTH
static final int DEFAULT_THREADS
Runtime.getRuntime().availableProcessors() * 2
.static final int DEFAULT_MAX_CHUNK_SIZE
Defaults to 8192.
getMaxChunkSize()
,
Constant Field Valuesstatic ServerConfigBuilder embedded()
static ServerConfigBuilder builder()
builder
in interface ConfigData
static ServerConfig of(Action<? super ServerConfigBuilder> action) throws Exception
Exception
int getPort()
Defaults to 5050.
@Nullable InetAddress getAddress()
A value of null causes all interfaces to be bound. Defaults to null.
ImmutableSet<ConfigObject<?>> getRequiredConfig()
Required config is declared via the ServerConfigBuilder.require(String, Class)
when building.
All required config is made part of the base registry (which the server registry joins with),
which automatically makes the config objects available to the server registry.
ServerConfigBuilder.require(String, Class)
boolean isDevelopment()
A flag for indicating to Ratpack internals that the app is under development; diagnostics and reloading are more important than performance and security.
In development mode Ratpack will leak internal information through diagnostics and stacktraces by sending them to the response.
true
if the server is in "development" modeint getThreads()
If the value is greater than 0, a thread pool (of this size) will be created for servicing requests and doing computation.
If the value is 0 (default) or less, a thread pool of size Runtime.availableProcessors()
* 2
will be used.
This effectively sizes the ExecController.getExecutor()
thread pool size.
URI getPublicAddress()
@Nullable SSLContext getSslContext()
null
if the application does not use SSL.boolean isRequireClientSslAuth()
SSLEngine.setNeedClientAuth(boolean)
.int getMaxContentLength()
Optional<Integer> getConnectTimeoutMillis()
Optional<Integer> getMaxMessagesPerRead()
If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.
Optional<Integer> getReceiveBufferSize()
Optional<Integer> getWriteSpinCount()
It is similar to what a spin lock is used for in concurrency programming. It improves memory utilization and write throughput depending on the platform that JVM runs on.
boolean isHasBaseDir()
int getMaxChunkSize()
This value is used to determine the size of chunks to emit when consuming request/response bodies. This generally only has an impact when consuming the body as a stream. A lower value will reduce memory pressure by requiring less memory at one time, but at the expense of throughput.
Defaults to DEFAULT_MAX_CHUNK_SIZE
.
This value is suitable for most applications.
If your application deals with very large bodies, you may want to increase it.
FileSystemBinding getBaseDir() throws NoBaseDirException
FileSystemBinding
.NoBaseDirException
- if this launch config has no base dir set.