Package org.springframework.r2dbc.core
Interface ConnectionAccessor
- All Known Subinterfaces:
DatabaseClient
public interface ConnectionAccessor
Interface declaring methods that accept callback
Function
to operate within the scope of a Connection.
Callback functions operate on a provided connection and must not
close the connection as the connections may be pooled or be
subject to other kinds of resource management.
Callback functions are responsible for creating a
Publisher that defines the scope of how
long the allocated Connection is valid. Connections are
released after the publisher terminates.
- Since:
- 5.3
- Author:
- Mark Paluch
-
Method Summary
Modifier and TypeMethodDescription<T> reactor.core.publisher.Mono<T>inConnection(Function<Connection, reactor.core.publisher.Mono<T>> action) Execute a callbackFunctionwithin aConnectionscope.<T> reactor.core.publisher.Flux<T>inConnectionMany(Function<Connection, reactor.core.publisher.Flux<T>> action) Execute a callbackFunctionwithin aConnectionscope.
-
Method Details
-
inConnection
<T> reactor.core.publisher.Mono<T> inConnection(Function<Connection, reactor.core.publisher.Mono<T>> action) throws DataAccessExceptionExecute a callbackFunctionwithin aConnectionscope. The function is responsible for creating aMono. The connection is released after theMonoterminates (or the subscription is cancelled). Connection resources must not be passed outside of theFunctionclosure, otherwise resources may get defunct.- Parameters:
action- the callback object that specifies the connection action- Returns:
- the resulting
Mono - Throws:
DataAccessException
-
inConnectionMany
<T> reactor.core.publisher.Flux<T> inConnectionMany(Function<Connection, reactor.core.publisher.Flux<T>> action) throws DataAccessExceptionExecute a callbackFunctionwithin aConnectionscope. The function is responsible for creating aFlux. The connection is released after theFluxterminates (or the subscription is cancelled). Connection resources must not be passed outside of theFunctionclosure, otherwise resources may get defunct.- Parameters:
action- the callback object that specifies the connection action- Returns:
- the resulting
Flux - Throws:
DataAccessException
-