Interface ConnectionProvider
- All Superinterfaces:
Disposable
- All Known Implementing Classes:
HttpResources,PooledConnectionProvider,TcpResources
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ConnectionProvider will produce Connection.- Since:
- 0.8
- Author:
- Stephane Maldini
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic final classBuild aConnectionProviderto cache and reuse a fixed maximum number ofConnection.static interfacestatic classConfiguration for a connection pool.static final classConfiguration for a connection pool per remote host.static interfaceA strategy to register which metrics are collected in a particular connection pool.Nested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault acquisition timeout (milliseconds) before error.static final StringDefault leasing strategy (fifo, lifo), fallback to fifo.static final intDefault max connections.static final longDefault max idle time, fallback - max idle time is not specified.static final longDefault max life time, fallback - max life time is not specified.static final StringThe connection selection is first in, first out.static final StringThe connection selection is last in, first out. -
Method Summary
Modifier and TypeMethodDescriptionMono<? extends Connection>acquire(TransportConfig config, ConnectionObserver connectionObserver, @Nullable Supplier<? extends SocketAddress> remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) Return an existing or newConnectionon subscribe.static ConnectionProvider.BuilderCreates a builder forConnectionProvider.static ConnectionProviderCreate a newConnectionProviderto cache and reuse a fixed maximum number ofConnection.static ConnectionProviderCreate a newConnectionProviderto cache and reuse a fixed maximum number ofConnection.static ConnectionProviderCreate a newConnectionProviderto cache and reuse a fixed maximum number ofConnection.default voiddispose()Dispose this ConnectionProvider.Returns a Mono that triggers the disposal of the ConnectionProvider when subscribed to.default voiddisposeWhen(SocketAddress remoteAddress) Dispose all connection pools for the specified remote address.default intReturns the maximum number of connections before starting pending.default @Nullable Map<SocketAddress,Integer> Returns the maximum number of connections per host before starting pending.default @Nullable ConnectionProvider.Buildermutate()Returns a builder to mutate properties of thisConnectionProvider.default @Nullable Stringname()ReturnsConnectionProvidername used for metrics.static ConnectionProviderReturn aConnectionProviderthat will always create a newConnection.Methods inherited from interface reactor.core.Disposable
isDisposed
-
Field Details
-
DEFAULT_POOL_MAX_CONNECTIONS
static final int DEFAULT_POOL_MAX_CONNECTIONSDefault max connections. Fallback to 2 * available number of processors (but with a minimum value of 16) -
DEFAULT_POOL_ACQUIRE_TIMEOUT
static final long DEFAULT_POOL_ACQUIRE_TIMEOUTDefault acquisition timeout (milliseconds) before error. If -1 will never wait to acquire before opening a new connection in an unbounded fashion. Fallback 45 seconds -
DEFAULT_POOL_MAX_IDLE_TIME
static final long DEFAULT_POOL_MAX_IDLE_TIMEDefault max idle time, fallback - max idle time is not specified. -
DEFAULT_POOL_MAX_LIFE_TIME
static final long DEFAULT_POOL_MAX_LIFE_TIMEDefault max life time, fallback - max life time is not specified. -
LEASING_STRATEGY_FIFO
The connection selection is first in, first out.- See Also:
-
LEASING_STRATEGY_LIFO
The connection selection is last in, first out.- See Also:
-
DEFAULT_POOL_LEASING_STRATEGY
Default leasing strategy (fifo, lifo), fallback to fifo.- fifo - The connection selection is first in, first out
- lifo - The connection selection is last in, first out
-
-
Method Details
-
builder
Creates a builder forConnectionProvider.- Parameters:
name-ConnectionProvidername- Returns:
- a new ConnectionProvider builder
- Since:
- 0.9.5
-
newConnection
Return aConnectionProviderthat will always create a newConnection.- Returns:
- a
ConnectionProviderthat will always create a newConnection.
-
create
Create a newConnectionProviderto cache and reuse a fixed maximum number ofConnection.A Fixed
ConnectionProviderwill open up to the given max number of processors observed by this jvm (minimum 4). Further connections will be pending acquisition untilDEFAULT_POOL_ACQUIRE_TIMEOUTand the default pending acquisition max count will be 500.- Parameters:
name- the connection pool name- Returns:
- a new
ConnectionProviderto cache and reuse a fixed maximum number ofConnection - Since:
- 0.9.5
-
create
Create a newConnectionProviderto cache and reuse a fixed maximum number ofConnection.A Fixed
ConnectionProviderwill open up to the given max connection value. Further connections will be pending acquisition untilDEFAULT_POOL_ACQUIRE_TIMEOUTand the default pending acquisition max count will be 2 * max connections value.- Parameters:
name- the connection pool namemaxConnections- the maximum number of connections before starting pending acquisition on existing ones- Returns:
- a new
ConnectionProviderto cache and reuse a fixed maximum number ofConnection - Since:
- 0.9.5
-
create
Create a newConnectionProviderto cache and reuse a fixed maximum number ofConnection.A Fixed
ConnectionProviderwill open up to the given max connection value. Further connections will be pending acquisition untilDEFAULT_POOL_ACQUIRE_TIMEOUTand the default pending acquisition max count will be 2 * max connections value.- Parameters:
name- the connection pool namemaxConnections- the maximum number of connections before starting pending acquisition on existing onesmetricsEnabled- true enables metrics collection; false disables it- Returns:
- a new
ConnectionProviderto cache and reuse a fixed maximum number ofConnection - Since:
- 1.0.21
-
acquire
Mono<? extends Connection> acquire(TransportConfig config, ConnectionObserver connectionObserver, @Nullable Supplier<? extends SocketAddress> remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) Return an existing or newConnectionon subscribe.- Parameters:
config- the transport configurationconnectionObserver- theConnectionObserverremoteAddress- theSocketAddressto connect toresolverGroup- the resolver which will resolve the address of the unresolved named address- Returns:
- an existing or new
MonoofConnection
-
disposeWhen
Dispose all connection pools for the specified remote address.This method has
NOOPdefault implementation.ConnectionProviderimplementations may decide to provide more specific implementation.- Parameters:
remoteAddress- the remote address
-
dispose
default void dispose()Dispose this ConnectionProvider. This method is NOT blocking. It is implemented as fire-and-forget. UsedisposeLater()when you need to observe the final status of the operation, combined withMono.block()if you need to synchronously wait for the underlying resources to be disposed.- Specified by:
disposein interfaceDisposable
-
disposeLater
Returns a Mono that triggers the disposal of the ConnectionProvider when subscribed to.This method has
NOOPdefault implementation.ConnectionProviderimplementations may decide to provide more specific implementation.- Returns:
- a Mono representing the completion of the ConnectionProvider disposal.
-
maxConnections
default int maxConnections()Returns the maximum number of connections before starting pending.- Returns:
- the maximum number of connections before starting pending
-
maxConnectionsPerHost
Returns the maximum number of connections per host before starting pending.- Returns:
- the maximum number of connections per host before starting pending
-
mutate
Returns a builder to mutate properties of thisConnectionProvider.- Returns:
- a builder to mutate properties of this
ConnectionProvider - Since:
- 1.0.14
-
name
ReturnsConnectionProvidername used for metrics.- Returns:
ConnectionProvidername used for metrics- Since:
- 1.0.14
-