DatabaseModuleBase

io.github.gaelrenoux.tranzactio.DatabaseModuleBase
abstract class DatabaseModuleBase[Connection, Database <: ServiceOps[Connection], DbContext] extends ModuleOps[Connection, Database]

Template implementing the commodity methods for a Db module.

Attributes

Graph
Supertypes
trait ModuleOps[Connection, Database]
trait DatabaseOps[Connection, Database]
class Object
trait Matchable
class Any
Known subtypes
trait DatabaseModuleTestOps[Connection, DbContext]
class Module[M, Connection, DbContext]

Members list

Type members

Types

type Service = ServiceOps[Connection]

Value members

Abstract methods

def fromConnectionSource(implicit dbContext: DbContext, trace: Trace): ZLayer[ConnectionSource, Nothing, Database]

Creates a Database Layer which requires an existing ConnectionSource.

Creates a Database Layer which requires an existing ConnectionSource.

Attributes

Concrete methods

override def autoCommit[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[Database & R, Either[DbException, E], A]

Provides that ZIO with a Connection. All DB action in the ZIO will be auto-committed. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

Provides that ZIO with a Connection. All DB action in the ZIO will be auto-committed. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

This method should be implemented by subclasses, to provide the connection.

Attributes

Definition Classes
override def autoCommitStream[R, E, A](stream: => ZStream[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[Database & R, Either[DbException, E], A]

As autoCommit, for ZStream instances instead of ZIO instances.

As autoCommit, for ZStream instances instead of ZIO instances.

This method should be implemented by subclasses, to provide the connection.

Attributes

Definition Classes
final def fromDatasource(implicit dbContext: DbContext, trace: Trace): ZLayer[DataSource, Nothing, Database]

Commodity method: creates a Database Layer which includes its own ConnectionSource based on a DataSource. Most connection pool implementations should be able to provide you a DataSource.

Commodity method: creates a Database Layer which includes its own ConnectionSource based on a DataSource. Most connection pool implementations should be able to provide you a DataSource.

When no implicit ErrorStrategies is available, the default ErrorStrategies will be used.

Attributes

final def fromDatasource(errorStrategies: ErrorStrategiesRef)(implicit dbContext: DbContext, trace: Trace): ZLayer[DataSource, Nothing, Database]

As fromDatasource, but provides a default ErrorStrategiesRef. When a method is called with no available implicit ErrorStrategiesRef, the ErrorStrategiesRef in argument will be used.

As fromDatasource, but provides a default ErrorStrategiesRef. When a method is called with no available implicit ErrorStrategiesRef, the ErrorStrategiesRef in argument will be used.

Attributes

final def fromDatasourceAndErrorStrategies(implicit dbContext: DbContext, trace: Trace): ZLayer[DataSource & ErrorStrategies, Nothing, Database]

As fromDatasource(ErrorStrategiesRef), but an ErrorStrategies is provided through a layer instead of as a parameter.

As fromDatasource(ErrorStrategiesRef), but an ErrorStrategies is provided through a layer instead of as a parameter.

Attributes

override def transaction[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[Database & R, Either[DbException, E], A]

Provides that ZIO with a Connection. A transaction will be opened before any actions in the ZIO, and closed after. It will commit only if the ZIO succeeds, and rollback otherwise. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

Provides that ZIO with a Connection. A transaction will be opened before any actions in the ZIO, and closed after. It will commit only if the ZIO succeeds, and rollback otherwise. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

This method should be implemented by subclasses, to provide the connection.

Attributes

Definition Classes
override def transactionOrDieStream[R, E, A](stream: => ZStream[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[Database & R, E, A]

As transactionOrDie, for ZStream instances instead of ZIO instances.

As transactionOrDie, for ZStream instances instead of ZIO instances.

Attributes

Definition Classes

Inherited methods

final def autoCommitOrDie[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As autoCommit, but errors when handling the connections are treated as defects instead of failures.

As autoCommit, but errors when handling the connections are treated as defects instead of failures.

Attributes

Inherited from:
DatabaseOps
final def autoCommitOrDieStream[R, E, A](stream: => ZStream[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[R & R0, E, A]

As autoCommitOrDie, for ZStream instances instead of ZIO instances.

As autoCommitOrDie, for ZStream instances instead of ZIO instances.

Attributes

Inherited from:
DatabaseOps
final def autoCommitOrWiden[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As autoCommit, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

As autoCommit, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

Attributes

Inherited from:
DatabaseOps
final def autoCommitOrWidenStream[R, E >: DbException, A](stream: => ZStream[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[R & R0, E, A]

As autoCommitOrWiden, for ZStream instances instead of ZIO instances.

As autoCommitOrWiden, for ZStream instances instead of ZIO instances.

Attributes

Inherited from:
DatabaseOps
final def transactionOrDie[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As transaction, but errors when handling the connections are treated as defects instead of failures.

As transaction, but errors when handling the connections are treated as defects instead of failures.

Attributes

Inherited from:
DatabaseOps
final def transactionOrWiden[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As transaction, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

As transaction, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

Attributes

Inherited from:
DatabaseOps

Deprecated and Inherited methods

final def autoCommitOrDieR[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def autoCommitOrWidenR[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def autoCommitR[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, Either[DbException, E], A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def transactionOrDieR[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def transactionOrWidenR[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def transactionR[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, Either[DbException, E], A]

Attributes

Deprecated
[Since version 0.4.0]
Inherited from:
DatabaseOps