Commit b55693b6 authored by Savorboard's avatar Savorboard

add summary comment

parent 4abfb252
......@@ -118,7 +118,7 @@ public class PublishController : Controller
{
//your business code
_capBus.Publish(""xxx.services.show.time", DateTime.Now);
_capBus.Publish("xxx.services.show.time", DateTime.Now);
}
return Ok();
......
......@@ -58,6 +58,13 @@ namespace DotNetCore.CAP
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,
ICapPublisher publisher, bool autoCommit = false)
{
......
......@@ -74,6 +74,13 @@ namespace DotNetCore.CAP
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,
ICapPublisher publisher, bool autoCommit = false)
{
......@@ -82,6 +89,13 @@ namespace DotNetCore.CAP
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,
ICapPublisher publisher, bool autoCommit = false)
{
......
......@@ -73,6 +73,13 @@ namespace DotNetCore.CAP
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,
ICapPublisher publisher, bool autoCommit = false)
{
......@@ -85,6 +92,13 @@ namespace DotNetCore.CAP
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,
ICapPublisher publisher, bool autoCommit = false)
{
......
......@@ -122,6 +122,22 @@ namespace DotNetCore.CAP
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,
ICapPublisher publisher, bool autoCommit = false)
{
......@@ -135,15 +151,13 @@ namespace DotNetCore.CAP
return (IDbTransaction)capTransaction.DbTransaction;
}
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="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,
ICapPublisher publisher, bool autoCommit = false)
{
......
......@@ -11,6 +11,9 @@ namespace DotNetCore.CAP
/// </summary>
public interface ICapPublisher
{
/// <summary>
/// CAP transaction context object
/// </summary>
ICapTransaction Transaction { get; }
/// <summary>
......
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
{
/// <summary>
/// CAP transaction wrapper, used to wrap database transactions, provides a consistent user interface
/// </summary>
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; }
/// <summary>
/// Database transaction object, can be converted to a specific database transaction object or IDBTransaction when used
/// </summary>
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();
/// <summary>
/// We will delete the message data that has not been sstore in the buffer data of current transaction context.
/// </summary>
void Rollback();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment