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
b55693b6
Commit
b55693b6
authored
Aug 30, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add summary comment
parent
4abfb252
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
12 deletions
+82
-12
README.md
README.md
+1
-1
ICapTransaction.MongoDB.cs
src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs
+7
-0
ICapTransaction.MySql.cs
src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs
+14
-0
ICapTransaction.PostgreSql.cs
src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs
+14
-0
ICapTransaction.SqlServer.cs
src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs
+23
-9
ICapPublisher.cs
src/DotNetCore.CAP/ICapPublisher.cs
+3
-0
ICapTransaction.cs
src/DotNetCore.CAP/ICapTransaction.cs
+20
-2
No files found.
README.md
View file @
b55693b6
...
@@ -118,7 +118,7 @@ public class PublishController : Controller
...
@@ -118,7 +118,7 @@ public class PublishController : Controller
{
{
//your business code
//your business code
_capBus
.
Publish
(
"
"
xxx
.
services
.
show
.
time
", DateTime.Now);
_capBus
.
Publish
(
"xxx.services.show.time"
,
DateTime
.
Now
);
}
}
return
Ok
();
return
Ok
();
...
...
src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs
View file @
b55693b6
...
@@ -58,6 +58,13 @@ namespace DotNetCore.CAP
...
@@ -58,6 +58,13 @@ namespace DotNetCore.CAP
return
transaction
;
return
transaction
;
}
}
/// <summary>
/// Start the CAP transaction
/// </summary>
/// <param name="client">The <see cref="IMongoClient"/>.</param>
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
/// <returns>The <see cref="IClientSessionHandle"/> of MongoDB transaction session object.</returns>
public
static
IClientSessionHandle
StartTransaction
(
this
IMongoClient
client
,
public
static
IClientSessionHandle
StartTransaction
(
this
IMongoClient
client
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
...
src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs
View file @
b55693b6
...
@@ -74,6 +74,13 @@ namespace DotNetCore.CAP
...
@@ -74,6 +74,13 @@ namespace DotNetCore.CAP
return
transaction
;
return
transaction
;
}
}
/// <summary>
/// Start the CAP transaction
/// </summary>
/// <param name="database">The <see cref="DatabaseFacade"/>.</param>
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
/// <returns>The <see cref="IDbContextTransaction"/> of EF dbcontext transaction object.</returns>
public
static
IDbContextTransaction
BeginTransaction
(
this
DatabaseFacade
database
,
public
static
IDbContextTransaction
BeginTransaction
(
this
DatabaseFacade
database
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
@@ -82,6 +89,13 @@ namespace DotNetCore.CAP
...
@@ -82,6 +89,13 @@ namespace DotNetCore.CAP
return
new
CapEFDbTransaction
(
capTrans
);
return
new
CapEFDbTransaction
(
capTrans
);
}
}
/// <summary>
/// Start the CAP transaction
/// </summary>
/// <param name="dbConnection">The <see cref="IDbConnection"/>.</param>
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
/// <returns>The <see cref="ICapTransaction"/> object.</returns>
public
static
ICapTransaction
BeginTransaction
(
this
IDbConnection
dbConnection
,
public
static
ICapTransaction
BeginTransaction
(
this
IDbConnection
dbConnection
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
...
src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs
View file @
b55693b6
...
@@ -73,6 +73,13 @@ namespace DotNetCore.CAP
...
@@ -73,6 +73,13 @@ namespace DotNetCore.CAP
return
transaction
;
return
transaction
;
}
}
/// <summary>
/// Start the CAP transaction
/// </summary>
/// <param name="dbConnection">The <see cref="IDbConnection"/>.</param>
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
/// <returns>The <see cref="ICapTransaction"/> object.</returns>
public
static
ICapTransaction
BeginTransaction
(
this
IDbConnection
dbConnection
,
public
static
ICapTransaction
BeginTransaction
(
this
IDbConnection
dbConnection
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
@@ -85,6 +92,13 @@ namespace DotNetCore.CAP
...
@@ -85,6 +92,13 @@ namespace DotNetCore.CAP
return
publisher
.
Transaction
.
Begin
(
dbTransaction
,
autoCommit
);
return
publisher
.
Transaction
.
Begin
(
dbTransaction
,
autoCommit
);
}
}
/// <summary>
/// Start the CAP transaction
/// </summary>
/// <param name="database">The <see cref="DatabaseFacade"/>.</param>
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
/// <returns>The <see cref="IDbContextTransaction"/> of EF dbcontext transaction object.</returns>
public
static
IDbContextTransaction
BeginTransaction
(
this
DatabaseFacade
database
,
public
static
IDbContextTransaction
BeginTransaction
(
this
DatabaseFacade
database
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
...
src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs
View file @
b55693b6
...
@@ -122,6 +122,22 @@ namespace DotNetCore.CAP
...
@@ -122,6 +122,22 @@ namespace DotNetCore.CAP
return
transaction
;
return
transaction
;
}
}
public
static
ICapTransaction
Begin
(
this
ICapTransaction
transaction
,
IDbContextTransaction
dbTransaction
,
bool
autoCommit
=
false
)
{
transaction
.
DbTransaction
=
dbTransaction
;
transaction
.
AutoCommit
=
autoCommit
;
return
transaction
;
}
/// <summary>
/// Start the CAP transaction
/// </summary>
/// <param name="dbConnection">The <see cref="IDbConnection"/>.</param>
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
/// <returns>The <see cref="ICapTransaction"/> object.</returns>
public
static
IDbTransaction
BeginTransaction
(
this
IDbConnection
dbConnection
,
public
static
IDbTransaction
BeginTransaction
(
this
IDbConnection
dbConnection
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
@@ -135,15 +151,13 @@ namespace DotNetCore.CAP
...
@@ -135,15 +151,13 @@ namespace DotNetCore.CAP
return
(
IDbTransaction
)
capTransaction
.
DbTransaction
;
return
(
IDbTransaction
)
capTransaction
.
DbTransaction
;
}
}
public
static
ICapTransaction
Begin
(
this
ICapTransaction
transaction
,
/// <summary>
IDbContextTransaction
dbTransaction
,
bool
autoCommit
=
false
)
/// Start the CAP transaction
{
/// </summary>
transaction
.
DbTransaction
=
dbTransaction
;
/// <param name="database">The <see cref="DatabaseFacade"/>.</param>
transaction
.
AutoCommit
=
autoCommit
;
/// <param name="publisher">The <see cref="ICapPublisher"/>.</param>
/// <param name="autoCommit">Whether the transaction is automatically committed when the message is published</param>
return
transaction
;
/// <returns>The <see cref="IDbContextTransaction"/> of EF dbcontext transaction object.</returns>
}
public
static
IDbContextTransaction
BeginTransaction
(
this
DatabaseFacade
database
,
public
static
IDbContextTransaction
BeginTransaction
(
this
DatabaseFacade
database
,
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
ICapPublisher
publisher
,
bool
autoCommit
=
false
)
{
{
...
...
src/DotNetCore.CAP/ICapPublisher.cs
View file @
b55693b6
...
@@ -11,6 +11,9 @@ namespace DotNetCore.CAP
...
@@ -11,6 +11,9 @@ namespace DotNetCore.CAP
/// </summary>
/// </summary>
public
interface
ICapPublisher
public
interface
ICapPublisher
{
{
/// <summary>
/// CAP transaction context object
/// </summary>
ICapTransaction
Transaction
{
get
;
}
ICapTransaction
Transaction
{
get
;
}
/// <summary>
/// <summary>
...
...
src/DotNetCore.CAP/ICapTransaction.cs
View file @
b55693b6
using
System
;
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System
;
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
/// <summary>
/// CAP transaction wrapper, used to wrap database transactions, provides a consistent user interface
/// </summary>
public
interface
ICapTransaction
:
IDisposable
public
interface
ICapTransaction
:
IDisposable
{
{
/// <summary>
/// A flag is used to indicate whether the transaction is automatically committed after the message is published
/// </summary>
bool
AutoCommit
{
get
;
set
;
}
bool
AutoCommit
{
get
;
set
;
}
/// <summary>
/// Database transaction object, can be converted to a specific database transaction object or IDBTransaction when used
/// </summary>
object
DbTransaction
{
get
;
set
;
}
object
DbTransaction
{
get
;
set
;
}
/// <summary>
/// Submit the transaction context of the CAP, we will send the message to the message queue at the time of submission
/// </summary>
void
Commit
();
void
Commit
();
/// <summary>
/// We will delete the message data that has not been sstore in the buffer data of current transaction context.
/// </summary>
void
Rollback
();
void
Rollback
();
}
}
}
}
\ 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