瀏覽代碼

add impl for ICapTransaction

master
Savorboard 6 年之前
父節點
當前提交
764e23fa32
共有 1 個檔案被更改,包括 41 行新增0 行删除
  1. +41
    -0
      src/DotNetCore.CAP/ICapTransaction.Base.cs

+ 41
- 0
src/DotNetCore.CAP/ICapTransaction.Base.cs 查看文件

@@ -0,0 +1,41 @@
using System.Collections.Generic;
using DotNetCore.CAP.Models;

namespace DotNetCore.CAP
{
public abstract class CapTransactionBase : ICapTransaction
{
private readonly IDispatcher _dispatcher;

private readonly IList<CapPublishedMessage> _bufferList;

protected CapTransactionBase(IDispatcher dispatcher)
{
_dispatcher = dispatcher;
_bufferList = new List<CapPublishedMessage>(1);
}

public bool AutoCommit { get; set; }

public object DbTransaction { get; set; }

protected internal void AddToSent(CapPublishedMessage msg)
{
_bufferList.Add(msg);
}
protected void Flush()
{
foreach (var message in _bufferList)
{
_dispatcher.EnqueueToPublish(message);
}
}

public abstract void Commit();

public abstract void Rollback();

public abstract void Dispose();
}
}

Loading…
取消
儲存