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.

  This serves as a base interface for `DatabaseClient`.

  Since:
    5.3
  Author:
    Mark Paluch
  See Also:
    `DatabaseClient`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> reactor.core.publisher.Mono<T>` | `inConnection(Function<io.r2dbc.spi.Connection,reactor.core.publisher.Mono<T>> action)` Execute a callback `Function` within a `Connection` scope.
    `<T> reactor.core.publisher.Flux<T>` | `inConnectionMany(Function<io.r2dbc.spi.Connection,reactor.core.publisher.Flux<T>> action)` Execute a callback `Function` within a `Connection` scope.

- - ### Method Detail

    - #### inConnection

          <T> reactor.core.publisher.Mono<T> inConnection(Function<io.r2dbc.spi.Connection,reactor.core.publisher.Mono<T>> action)

      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` - in case of any errors

    - #### inConnectionMany

          <T> reactor.core.publisher.Flux<T> inConnectionMany(Function<io.r2dbc.spi.Connection,reactor.core.publisher.Flux<T>> action)

      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` - in case of any errors