Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
ce06c23c
Commit
ce06c23c
authored
Oct 31, 2019
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add async support for CAPTransaction
parent
c99869fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
2 deletions
+65
-2
ICapTransaction.MySql.cs
src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs
+33
-0
IDbContextTransaction.CAP.cs
src/DotNetCore.CAP.MySql/IDbContextTransaction.CAP.cs
+20
-2
ICapTransaction.Base.cs
src/DotNetCore.CAP/ICapTransaction.Base.cs
+6
-0
ICapTransaction.cs
src/DotNetCore.CAP/ICapTransaction.cs
+6
-0
No files found.
src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs
View file @
ce06c23c
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
using
System.Data
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Storage
;
using
Microsoft.EntityFrameworkCore.Storage
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
...
@@ -33,6 +35,22 @@ namespace DotNetCore.CAP
...
@@ -33,6 +35,22 @@ namespace DotNetCore.CAP
Flush
();
Flush
();
}
}
public
override
async
Task
CommitAsync
(
CancellationToken
cancellationToken
=
default
)
{
Debug
.
Assert
(
DbTransaction
!=
null
);
switch
(
DbTransaction
)
{
case
IDbTransaction
dbTransaction
:
dbTransaction
.
Commit
();
break
;
case
IDbContextTransaction
dbContextTransaction
:
await
dbContextTransaction
.
CommitAsync
(
cancellationToken
);
break
;
}
Flush
();
}
public
override
void
Rollback
()
public
override
void
Rollback
()
{
{
Debug
.
Assert
(
DbTransaction
!=
null
);
Debug
.
Assert
(
DbTransaction
!=
null
);
...
@@ -48,6 +66,21 @@ namespace DotNetCore.CAP
...
@@ -48,6 +66,21 @@ namespace DotNetCore.CAP
}
}
}
}
public
override
async
Task
RollbackAsync
(
CancellationToken
cancellationToken
=
default
)
{
Debug
.
Assert
(
DbTransaction
!=
null
);
switch
(
DbTransaction
)
{
case
IDbTransaction
dbTransaction
:
dbTransaction
.
Rollback
();
break
;
case
IDbContextTransaction
dbContextTransaction
:
await
dbContextTransaction
.
RollbackAsync
(
cancellationToken
);
break
;
}
}
public
override
void
Dispose
()
public
override
void
Dispose
()
{
{
(
DbTransaction
as
IDbTransaction
)?.
Dispose
();
(
DbTransaction
as
IDbTransaction
)?.
Dispose
();
...
...
src/DotNetCore.CAP.MySql/IDbContextTransaction.CAP.cs
View file @
ce06c23c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System
;
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP
;
using
DotNetCore.CAP
;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
...
@@ -15,10 +17,12 @@ namespace Microsoft.EntityFrameworkCore.Storage
...
@@ -15,10 +17,12 @@ namespace Microsoft.EntityFrameworkCore.Storage
public
CapEFDbTransaction
(
ICapTransaction
transaction
)
public
CapEFDbTransaction
(
ICapTransaction
transaction
)
{
{
_transaction
=
transaction
;
_transaction
=
transaction
;
var
dbContextTransaction
=
(
IDbContextTransaction
)
_transaction
.
DbTransaction
;
var
dbContextTransaction
=
(
IDbContextTransaction
)
_transaction
.
DbTransaction
;
TransactionId
=
dbContextTransaction
.
TransactionId
;
TransactionId
=
dbContextTransaction
.
TransactionId
;
}
}
public
Guid
TransactionId
{
get
;
}
public
void
Dispose
()
public
void
Dispose
()
{
{
_transaction
.
Dispose
();
_transaction
.
Dispose
();
...
@@ -29,11 +33,25 @@ namespace Microsoft.EntityFrameworkCore.Storage
...
@@ -29,11 +33,25 @@ namespace Microsoft.EntityFrameworkCore.Storage
_transaction
.
Commit
();
_transaction
.
Commit
();
}
}
public
Task
CommitAsync
(
CancellationToken
cancellationToken
=
default
)
{
return
_transaction
.
CommitAsync
(
cancellationToken
);
}
public
void
Rollback
()
public
void
Rollback
()
{
{
_transaction
.
Rollback
();
_transaction
.
Rollback
();
}
}
public
Guid
TransactionId
{
get
;
}
public
Task
RollbackAsync
(
CancellationToken
cancellationToken
=
default
)
{
return
_transaction
.
CommitAsync
(
cancellationToken
);
}
public
ValueTask
DisposeAsync
()
{
Dispose
();
return
new
ValueTask
();
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP/ICapTransaction.Base.cs
View file @
ce06c23c
using
System.Collections.Concurrent
;
using
System.Collections.Concurrent
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Persistence
;
using
DotNetCore.CAP.Persistence
;
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
...
@@ -36,8 +38,12 @@ namespace DotNetCore.CAP
...
@@ -36,8 +38,12 @@ namespace DotNetCore.CAP
public
abstract
void
Commit
();
public
abstract
void
Commit
();
public
abstract
Task
CommitAsync
(
CancellationToken
cancellationToken
=
default
);
public
abstract
void
Rollback
();
public
abstract
void
Rollback
();
public
abstract
Task
RollbackAsync
(
CancellationToken
cancellationToken
=
default
);
public
abstract
void
Dispose
();
public
abstract
void
Dispose
();
}
}
}
}
src/DotNetCore.CAP/ICapTransaction.cs
View file @
ce06c23c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System
;
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
...
@@ -25,9 +27,13 @@ namespace DotNetCore.CAP
...
@@ -25,9 +27,13 @@ namespace DotNetCore.CAP
/// </summary>
/// </summary>
void
Commit
();
void
Commit
();
Task
CommitAsync
(
CancellationToken
cancellationToken
=
default
);
/// <summary>
/// <summary>
/// We will delete the message data that has not been sstore in the buffer data of current transaction context.
/// We will delete the message data that has not been sstore in the buffer data of current transaction context.
/// </summary>
/// </summary>
void
Rollback
();
void
Rollback
();
Task
RollbackAsync
(
CancellationToken
cancellationToken
=
default
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment