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 Details

    • inConnection

      <T> reactor.core.publisher.Mono<T> inConnection(Function<Connection,reactor.core.publisher.Mono<T>> action) throws DataAccessException
      Execute a callback Function within a Connection scope. The function is responsible for creating a Mono. The connection is released after the Mono terminates (or the subscription is cancelled). Connection resources must not be passed outside the Function closure, 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 DataAccessException
      Execute a callback Function within a Connection scope. The function is responsible for creating a Flux. The connection is released after the Flux terminates (or the subscription is cancelled). Connection resources must not be passed outside the Function closure, otherwise resources may get defunct.
      Parameters:
      action - the callback object that specifies the connection action
      Returns:
      the resulting Flux
      Throws:
      DataAccessException