Browse Source

add summary comment

master
Savorboard 6 years ago
parent
commit
b55693b6ef
7 changed files with 82 additions and 12 deletions
  1. +1
    -1
      README.md
  2. +7
    -0
      src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs
  3. +14
    -0
      src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs
  4. +14
    -0
      src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs
  5. +23
    -9
      src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs
  6. +3
    -0
      src/DotNetCore.CAP/ICapPublisher.cs
  7. +20
    -2
      src/DotNetCore.CAP/ICapTransaction.cs

+ 1
- 1
README.md View File

@@ -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();


+ 7
- 0
src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs View File

@@ -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)
{


+ 14
- 0
src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs View File

@@ -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)
{


+ 14
- 0
src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs View File

@@ -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)
{


+ 23
- 9
src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs View File

@@ -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)
{


+ 3
- 0
src/DotNetCore.CAP/ICapPublisher.cs View File

@@ -11,6 +11,9 @@ namespace DotNetCore.CAP
/// </summary>
public interface ICapPublisher
{
/// <summary>
/// CAP transaction context object
/// </summary>
ICapTransaction Transaction { get; }

/// <summary>


+ 20
- 2
src/DotNetCore.CAP/ICapTransaction.cs View File

@@ -1,15 +1,33 @@
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();
}
}
}

Loading…
Cancel
Save