Search in sources :

Example 1 with BeginTransactionRequest

use of com.google.firestore.v1.BeginTransactionRequest in project spring-cloud-gcp by spring-cloud.

the class ReactiveFirestoreTransactionManager method startTransaction.

private Mono<ReactiveFirestoreResourceHolder> startTransaction(TransactionDefinition definition) {
    TransactionOptions.Builder txOptions = definition.isReadOnly() ? TransactionOptions.newBuilder().setReadOnly(TransactionOptions.ReadOnly.newBuilder().build()) : TransactionOptions.newBuilder().setReadWrite(TransactionOptions.ReadWrite.newBuilder().build());
    BeginTransactionRequest beginTransactionRequest = BeginTransactionRequest.newBuilder().setOptions(txOptions).setDatabase(this.databasePath).build();
    return ObservableReactiveUtil.<BeginTransactionResponse>unaryCall(obs -> this.firestore.beginTransaction(beginTransactionRequest, obs)).map(beginTransactionResponse -> new ReactiveFirestoreResourceHolder(beginTransactionResponse.getTransaction()));
}
Also used : CommitResponse(com.google.firestore.v1.CommitResponse) FirestoreGrpc(com.google.firestore.v1.FirestoreGrpc) Util(org.springframework.cloud.gcp.data.firestore.util.Util) TransactionDefinition(org.springframework.transaction.TransactionDefinition) Mono(reactor.core.publisher.Mono) BeginTransactionRequest(com.google.firestore.v1.BeginTransactionRequest) ObservableReactiveUtil(org.springframework.cloud.gcp.data.firestore.util.ObservableReactiveUtil) AbstractReactiveTransactionManager(org.springframework.transaction.reactive.AbstractReactiveTransactionManager) ByteString(com.google.protobuf.ByteString) TransactionSynchronizationManager(org.springframework.transaction.reactive.TransactionSynchronizationManager) BeginTransactionResponse(com.google.firestore.v1.BeginTransactionResponse) Empty(com.google.protobuf.Empty) SmartTransactionObject(org.springframework.transaction.support.SmartTransactionObject) TransactionSystemException(org.springframework.transaction.TransactionSystemException) GenericReactiveTransaction(org.springframework.transaction.reactive.GenericReactiveTransaction) CommitRequest(com.google.firestore.v1.CommitRequest) TransactionOptions(com.google.firestore.v1.TransactionOptions) RollbackRequest(com.google.firestore.v1.RollbackRequest) TransactionException(org.springframework.transaction.TransactionException) Nullable(org.springframework.lang.Nullable) Assert(org.springframework.util.Assert) TransactionOptions(com.google.firestore.v1.TransactionOptions) BeginTransactionRequest(com.google.firestore.v1.BeginTransactionRequest)

Aggregations

BeginTransactionRequest (com.google.firestore.v1.BeginTransactionRequest)1 BeginTransactionResponse (com.google.firestore.v1.BeginTransactionResponse)1 CommitRequest (com.google.firestore.v1.CommitRequest)1 CommitResponse (com.google.firestore.v1.CommitResponse)1 FirestoreGrpc (com.google.firestore.v1.FirestoreGrpc)1 RollbackRequest (com.google.firestore.v1.RollbackRequest)1 TransactionOptions (com.google.firestore.v1.TransactionOptions)1 ByteString (com.google.protobuf.ByteString)1 Empty (com.google.protobuf.Empty)1 ObservableReactiveUtil (org.springframework.cloud.gcp.data.firestore.util.ObservableReactiveUtil)1 Util (org.springframework.cloud.gcp.data.firestore.util.Util)1 Nullable (org.springframework.lang.Nullable)1 TransactionDefinition (org.springframework.transaction.TransactionDefinition)1 TransactionException (org.springframework.transaction.TransactionException)1 TransactionSystemException (org.springframework.transaction.TransactionSystemException)1 AbstractReactiveTransactionManager (org.springframework.transaction.reactive.AbstractReactiveTransactionManager)1 GenericReactiveTransaction (org.springframework.transaction.reactive.GenericReactiveTransaction)1 TransactionSynchronizationManager (org.springframework.transaction.reactive.TransactionSynchronizationManager)1 SmartTransactionObject (org.springframework.transaction.support.SmartTransactionObject)1 Assert (org.springframework.util.Assert)1