Transactions

uk.gov.hmrc.mongo.transaction.Transactions
trait Transactions

Effectively provides the behaviour not available on org.mongodb.scala.ClientSession (driver-scala, nor com.mongodb.reactivestreams.client.ClientSession driver-reactive-streams) but is available on com.mongodb.client.ClientSession (driver-core).

It is recommended to use the Future variant (i.e. add .toFuture to all db calls), since the Observable variant has some surprises. E.g.

  • some commands return Observable[Void] which will ignore any following map/flatMap (e.g. for-comprehension steps)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

protected def mongoComponent: MongoComponent

Concrete methods

def withClientSession[A](f: ClientSession => Future[A])(implicit tc: TransactionConfiguration, ec: ExecutionContext): Future[A]
def withClientSession[A](f: ClientSession => Observable[A])(implicit tc: TransactionConfiguration): Observable[A]
def withSessionAndTransaction[A](f: ClientSession => Future[A])(implicit tc: TransactionConfiguration, ec: ExecutionContext): Future[A]
def withSessionAndTransaction[A](f: ClientSession => Observable[A])(implicit tc: TransactionConfiguration): Observable[A]
def withTransaction[A](session: ClientSession, f: => Future[A])(implicit tc: TransactionConfiguration, ec: ExecutionContext): Future[A]

A transaction is started before running the continuation. It will be committed or aborted depending on whether the callback executes successfully or not. It also provides retries for network issues See https://github.com/mongodb/mongo-java-driver/tree/r4.3.1/driver-core/src/test/resources/transactions-convenient-api#retry-timeout-is-enforced And https://docs.mongodb.com/manual/core/retryable-writes/#retryable-writes-and-multi-document-transactions

A transaction is started before running the continuation. It will be committed or aborted depending on whether the callback executes successfully or not. It also provides retries for network issues See https://github.com/mongodb/mongo-java-driver/tree/r4.3.1/driver-core/src/test/resources/transactions-convenient-api#retry-timeout-is-enforced And https://docs.mongodb.com/manual/core/retryable-writes/#retryable-writes-and-multi-document-transactions

Attributes

def withTransaction[A](session: ClientSession, f: => Observable[A])(implicit tc: TransactionConfiguration): Observable[A]

A transaction is started before running the continuation. It will be committed or aborted depending on whether the callback executes successfully or not. It also provides retries for network issues See https://github.com/mongodb/mongo-java-driver/tree/r4.3.1/driver-core/src/test/resources/transactions-convenient-api#retry-timeout-is-enforced And https://docs.mongodb.com/manual/core/retryable-writes/#retryable-writes-and-multi-document-transactions

A transaction is started before running the continuation. It will be committed or aborted depending on whether the callback executes successfully or not. It also provides retries for network issues See https://github.com/mongodb/mongo-java-driver/tree/r4.3.1/driver-core/src/test/resources/transactions-convenient-api#retry-timeout-is-enforced And https://docs.mongodb.com/manual/core/retryable-writes/#retryable-writes-and-multi-document-transactions

Attributes