public final class HttpResources extends TcpResources
ConnectionProvider.AllocationStrategy<A extends ConnectionProvider.AllocationStrategy<A>>, ConnectionProvider.Builder, ConnectionProvider.ConnectionMetadata, ConnectionProvider.ConnectionPoolSpec<SPEC extends ConnectionProvider.ConnectionPoolSpec<SPEC>>, ConnectionProvider.HostSpecificSpec, ConnectionProvider.MeterRegistrar
Disposable.Composite, Disposable.Swap
DEFAULT_POOL_ACQUIRE_TIMEOUT, DEFAULT_POOL_LEASING_STRATEGY, DEFAULT_POOL_MAX_CONNECTIONS, DEFAULT_POOL_MAX_IDLE_TIME, DEFAULT_POOL_MAX_LIFE_TIME, LEASING_STRATEGY_FIFO, LEASING_STRATEGY_LIFO
DEFAULT_IO_SELECT_COUNT, DEFAULT_IO_WORKER_COUNT, DEFAULT_NATIVE, DEFAULT_SHUTDOWN_QUIET_PERIOD, DEFAULT_SHUTDOWN_TIMEOUT
Modifier and Type | Method and Description |
---|---|
static void |
disposeLoopsAndConnections()
Shutdown the global
HttpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
static Mono<Void> |
disposeLoopsAndConnectionsLater()
Prepare to shutdown the global
HttpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
static Mono<Void> |
disposeLoopsAndConnectionsLater(Duration quietPeriod,
Duration timeout)
Prepare to shutdown the global
HttpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
void |
disposeWhen(SocketAddress remoteAddress)
Dispose all connection pools for the specified remote address.
|
static HttpResources |
get()
Return the global HTTP resources for event loops and pooling.
|
AddressResolverGroup<?> |
getOrCreateDefaultResolver()
Safely checks whether a name resolver exists and proceed with a creation if it does not exist.
|
ConnectionProvider |
getOrCreateHttp2ConnectionProvider(Function<ConnectionProvider,ConnectionProvider> create)
Safely checks whether a
ConnectionProvider for HTTP/2 traffic exists
and proceed with a creation if it does not exist. |
ConnectionProvider |
getOrCreateHttp3ConnectionProvider(Function<ConnectionProvider,ConnectionProvider> create)
Safely checks whether a
ConnectionProvider for HTTP/3 traffic exists
and proceed with a creation if it does not exist. |
static HttpResources |
reset()
Reset http resources to default and return its instance.
|
static HttpResources |
set(ConnectionProvider provider)
Update pooling resources and return the global HTTP/1.x resources.
|
static HttpResources |
set(LoopResources loops)
Update event loops resources and return the global HTTP/1.x resources.
|
_dispose, _disposeLater, acquire, daemon, dispose, disposeLater, disposeLater, getOrCreate, isDisposed, maxConnections, maxConnectionsPerHost, mutate, name, onChannel, onChannelClass, onClient, onServer, onServerSelect
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, create, create, create, newConnection
colocate, create, create, create, create, hasNativeSupport
public static void disposeLoopsAndConnections()
HttpResources
without resetting them,
effectively cleaning up associated resources without creating new ones.
This method is NOT blocking. It is implemented as fire-and-forget.
Use disposeLoopsAndConnectionsLater()
when you need to observe
the final status of the operation, combined with Mono.block()
if you need to synchronously wait for the underlying resources to be disposed.public static Mono<Void> disposeLoopsAndConnectionsLater()
HttpResources
without resetting them,
effectively cleaning up associated resources without creating new ones. This only
occurs when the returned Mono
is subscribed to.
The quiet period will be 2s
and the timeout will be 15s
Mono
triggering the disposeLoopsAndConnections()
when subscribed to.public static Mono<Void> disposeLoopsAndConnectionsLater(Duration quietPeriod, Duration timeout)
HttpResources
without resetting them,
effectively cleaning up associated resources without creating new ones. This only
occurs when the returned Mono
is subscribed to.
It is guaranteed that the disposal of the underlying LoopResources will not happen before
quietPeriod
is over. If a task is submitted during the quietPeriod
,
it is guaranteed to be accepted and the quietPeriod
will start over.quietPeriod
- the quiet period as described abovetimeout
- the maximum amount of time to wait until the disposal of the underlying
LoopResources regardless if a task was submitted during the quiet periodMono
triggering the disposeLoopsAndConnections()
when subscribed to.public static HttpResources get()
public static HttpResources reset()
public static HttpResources set(ConnectionProvider provider)
ConnectionProvider
will be disposed.provider
- a new ConnectionProvider
to replace the currentpublic static HttpResources set(LoopResources loops)
LoopResources
will be disposed.loops
- a new LoopResources
to replace the currentpublic void disposeWhen(SocketAddress remoteAddress)
TcpResources
As opposed to TcpResources.dispose()
, this method delegates to the underlying connection provider.
It has a global effect and removes all connection pools for this remote address from the
global TCP resources (making it closer to TcpResources.disposeLoopsAndConnections()
than
to TcpResources.dispose()
).
disposeWhen
in interface ConnectionProvider
disposeWhen
in class TcpResources
remoteAddress
- the remote addresspublic AddressResolverGroup<?> getOrCreateDefaultResolver()
TcpResources
LoopResources
that are configured.
Guarantees that always one and the same instance is returned for a given LoopResources
and if the LoopResources
is updated the name resolver is also updated.getOrCreateDefaultResolver
in class TcpResources
AddressResolverGroup
public ConnectionProvider getOrCreateHttp2ConnectionProvider(Function<ConnectionProvider,ConnectionProvider> create)
ConnectionProvider
for HTTP/2 traffic exists
and proceed with a creation if it does not exist.create
- the create function provides the current ConnectionProvider
for HTTP/1.1 traffic
in case some ConnectionProvider
configuration is needed.ConnectionProvider
for HTTP/2 trafficpublic ConnectionProvider getOrCreateHttp3ConnectionProvider(Function<ConnectionProvider,ConnectionProvider> create)
ConnectionProvider
for HTTP/3 traffic exists
and proceed with a creation if it does not exist.create
- the create function provides the current ConnectionProvider
for HTTP/1.1 traffic
in case some ConnectionProvider
configuration is needed.ConnectionProvider
for HTTP/3 traffic