Class SQLClientHelper


  • public class SQLClientHelper
    extends Object
    Utilities for generating observables with a SQLClient.
    Author:
    Thomas Segismont
    • Method Detail

      • txFlowableTransformer

        public static <T> io.reactivex.FlowableTransformer<T,​T> txFlowableTransformer​(SQLConnection sqlConnection)
        Creates a FlowableTransformer decorating a Flowable with transaction management for a given SQLConnection.

        If the upstream Flowable completes (onComplete), the transaction is committed. If the upstream Flowable emits an error (onError), the transaction is rollbacked.

        Eventually, the given SQLConnection is put back in autocommit mode.

        Type Parameters:
        T - the type of the items emitted by the upstream Flowable
        Parameters:
        sqlConnection - the SQLConnection used for database operations and transaction management
        Returns:
        a FlowableTransformer decorating a Flowable with transaction management
      • inTransactionFlowable

        public static <T> io.reactivex.Flowable<T> inTransactionFlowable​(SQLClient client,
                                                                         Function<SQLConnection,​io.reactivex.Flowable<T>> sourceSupplier)
        Generates a Flowable from SQLConnection operations executed inside a transaction.
        Type Parameters:
        T - the type of the items emitted by the Flowable
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Flowable generated by interacting with the given SQLConnection
        Returns:
        a Flowable generated from SQLConnection operations executed inside a transaction
      • txObservableTransformer

        public static <T> io.reactivex.ObservableTransformer<T,​T> txObservableTransformer​(SQLConnection sqlConnection)
        Creates a ObservableTransformer decorating an Observable with transaction management for a given SQLConnection.

        If the upstream Observable completes (onComplete), the transaction is committed. If the upstream Observable emits an error (onError), the transaction is rollbacked.

        Eventually, the given SQLConnection is put back in autocommit mode.

        Type Parameters:
        T - the type of the items emitted by the upstream Observable
        Parameters:
        sqlConnection - the SQLConnection used for database operations and transaction management
        Returns:
        a ObservableTransformer decorating an Observable with transaction management
      • inTransactionObservable

        public static <T> io.reactivex.Observable<T> inTransactionObservable​(SQLClient client,
                                                                             Function<SQLConnection,​io.reactivex.Observable<T>> sourceSupplier)
        Generates a Observable from SQLConnection operations executed inside a transaction.
        Type Parameters:
        T - the type of the items emitted by the Observable
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Observable generated by interacting with the given SQLConnection
        Returns:
        an Observable generated from SQLConnection operations executed inside a transaction
      • txSingleTransformer

        public static <T> io.reactivex.SingleTransformer<T,​T> txSingleTransformer​(SQLConnection sqlConnection)
        Creates a SingleTransformer decorating a Single with transaction management for a given SQLConnection.

        If the upstream Single emits a value (onSuccess), the transaction is committed. If the upstream Single emits an error (onError), the transaction is rollbacked.

        Eventually, the given SQLConnection is put back in autocommit mode.

        Type Parameters:
        T - the type of the item emitted by the upstream Single
        Parameters:
        sqlConnection - the SQLConnection used for database operations and transaction management
        Returns:
        a SingleTransformer decorating a Single with transaction management
      • inTransactionSingle

        public static <T> io.reactivex.Single<T> inTransactionSingle​(SQLClient client,
                                                                     Function<SQLConnection,​io.reactivex.Single<T>> sourceSupplier)
        Generates a Single from SQLConnection operations executed inside a transaction.
        Type Parameters:
        T - the type of the item emitted by the Single
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Single generated by interacting with the given SQLConnection
        Returns:
        a Single generated from SQLConnection operations executed inside a transaction
      • txMaybeTransformer

        public static <T> io.reactivex.MaybeTransformer<T,​T> txMaybeTransformer​(SQLConnection sqlConnection)
        Creates a MaybeTransformer decorating a Maybe with transaction management for a given SQLConnection.

        If the upstream Maybe emits a value (onSuccess) or completes (onComplete), the transaction is committed. If the upstream Maybe emits an error (onError), the transaction is rollbacked.

        Eventually, the given SQLConnection is put back in autocommit mode.

        Type Parameters:
        T - the type of the item emitted by the upstream Maybe
        Parameters:
        sqlConnection - the SQLConnection used for database operations and transaction management
        Returns:
        a MaybeTransformer decorating a Maybe with transaction management
      • inTransactionMaybe

        public static <T> io.reactivex.Maybe<T> inTransactionMaybe​(SQLClient client,
                                                                   Function<SQLConnection,​io.reactivex.Maybe<T>> sourceSupplier)
        Generates a Maybe from SQLConnection operations executed inside a transaction.
        Type Parameters:
        T - the type of the item emitted by the Maybe
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Maybe generated by interacting with the given SQLConnection
        Returns:
        a Maybe generated from SQLConnection operations executed inside a transaction
      • txCompletableTransformer

        public static io.reactivex.CompletableTransformer txCompletableTransformer​(SQLConnection sqlConnection)
        Creates a CompletableTransformer decorating a Completable with transaction management for a given SQLConnection.

        If the upstream Completable completes (onComplete), the transaction is committed. If the upstream Completable emits an error (onError), the transaction is rollbacked.

        Eventually, the given SQLConnection is put back in autocommit mode.

        Parameters:
        sqlConnection - the SQLConnection used for database operations and transaction management
        Returns:
        a CompletableTransformer decorating a Completable with transaction management
      • inTransactionCompletable

        public static io.reactivex.Completable inTransactionCompletable​(SQLClient client,
                                                                        Function<SQLConnection,​io.reactivex.Completable> sourceSupplier)
        Generates a Completable from SQLConnection operations executed inside a transaction.
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Completable generated by interacting with the given SQLConnection
        Returns:
        a Completable generated from SQLConnection operations executed inside a transaction
      • usingConnectionFlowable

        public static <T> io.reactivex.Flowable<T> usingConnectionFlowable​(SQLClient client,
                                                                           Function<SQLConnection,​io.reactivex.Flowable<T>> sourceSupplier)
        Generates a Flowable from SQLConnection operations.
        Type Parameters:
        T - the type of the items emitted by the Flowable
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Flowable generated by interacting with the given SQLConnection
        Returns:
        a Flowable generated from SQLConnection operations
      • usingConnectionObservable

        public static <T> io.reactivex.Observable<T> usingConnectionObservable​(SQLClient client,
                                                                               Function<SQLConnection,​io.reactivex.Observable<T>> sourceSupplier)
        Generates a Observable from SQLConnection operations.
        Type Parameters:
        T - the type of the items emitted by the Observable
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Observable generated by interacting with the given SQLConnection
        Returns:
        an Observable generated from SQLConnection operations
      • usingConnectionSingle

        public static <T> io.reactivex.Single<T> usingConnectionSingle​(SQLClient client,
                                                                       Function<SQLConnection,​io.reactivex.Single<T>> sourceSupplier)
        Generates a Single from SQLConnection operations.
        Type Parameters:
        T - the type of the item emitted by the Single
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Single generated by interacting with the given SQLConnection
        Returns:
        a Single generated from SQLConnection operations
      • usingConnectionMaybe

        public static <T> io.reactivex.Maybe<T> usingConnectionMaybe​(SQLClient client,
                                                                     Function<SQLConnection,​io.reactivex.Maybe<T>> sourceSupplier)
        Generates a Maybe from SQLConnection operations.
        Type Parameters:
        T - the type of the item emitted by the Maybe
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Maybe generated by interacting with the given SQLConnection
        Returns:
        a Maybe generated from SQLConnection operations
      • usingConnectionCompletable

        public static io.reactivex.Completable usingConnectionCompletable​(SQLClient client,
                                                                          Function<SQLConnection,​io.reactivex.Completable> sourceSupplier)
        Generates a Completable from SQLConnection operations.
        Parameters:
        client - the SQLClient
        sourceSupplier - a user-provided function returning a Completable generated by interacting with the given SQLConnection
        Returns:
        a Completable generated from SQLConnection operations