Skip to content

Commit

Permalink
feat(Barrier): add support for TransactionScopeAsyncFlowOption (#81)
Browse files Browse the repository at this point in the history
- Add new overload to Call method supporting TransactionScopeAsyncFlowOption
- Update existing Call method to use the new overload with TransactionScopeAsyncFlowOption.Suppress(default value)
  • Loading branch information
wooln authored Dec 7, 2024
1 parent 9f90cc1 commit aee2970
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/DtmCommon/Barrier/BranchBarrier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,20 @@ public async Task Call(DbConnection db, Func<DbTransaction, Task> busiCall)
throw;
}
}

public async Task Call(DbConnection db, Func<Task> busiCall, TransactionScopeOption transactionScope = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.Serializable)
{
await Call(db, busiCall, transactionScope, isolationLevel, TransactionScopeAsyncFlowOption.Suppress);
}

public async Task Call(DbConnection db, Func<Task> busiCall, TransactionScopeOption transactionScope = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.Serializable)
public async Task Call(DbConnection db, Func<Task> busiCall, TransactionScopeOption transactionScope, IsolationLevel isolationLevel, TransactionScopeAsyncFlowOption transactionScopeAsyncFlowOption)
{
this.BarrierID = this.BarrierID + 1;
var bid = this.BarrierID.ToString().PadLeft(2, '0');

// check the connection state
if (db.State != System.Data.ConnectionState.Open) await db.OpenAsync();
using (var scope = new TransactionScope(transactionScope, new TransactionOptions { IsolationLevel = isolationLevel }))
using (var scope = new TransactionScope(transactionScope, new TransactionOptions { IsolationLevel = isolationLevel }, transactionScopeAsyncFlowOption))
{
try
{
Expand Down

0 comments on commit aee2970

Please sign in to comment.