Skip to content

Commit

Permalink
增加Command接口定义;扩展ITransactionInitiator接口属性
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaroad committed Apr 29, 2020
1 parent 72c6636 commit 991566b
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 4 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ dotnet add package Eventual2PC

- `ProcessManager`: CQRS中的概念,作为事务相关消息路由的角色,负责响应 `DomainEvent``DomainException` 消息,并发送 `Command` 消息

#### Initiator 命令定义

- `AddPreCommitSucceedParticipant`: 添加预提交成功的参与方

- `AddPreCommitFailedParticipant`: 添加预提交失败的参与方

- `AddCommittedParticipant`: 添加已提交的参与方

- `AddRolledbackParticipant`: 添加已回滚的参与方

#### Initiator 事件定义

- `TransactionStarted`: 事务已发起事件
Expand All @@ -40,6 +50,14 @@ dotnet add package Eventual2PC

- `TransactionCompleted`: 事务已完成事件(Option),并包含是否事务已提交的状态

#### Participant 命令定义

- `PreCommit`: 预提交

- `Commit`: 提交

- `Rollback`: 回滚

#### Participant 事件定义

- `PreCommitSucceed`: 预提交已成功事件
Expand All @@ -50,7 +68,6 @@ dotnet add package Eventual2PC

- `Rolledback`: 已回滚事件


### 规约

- 一个聚合根,可以同时扮演 `Initiator``Transaction`的角色,如银行转账事务聚合根
Expand Down Expand Up @@ -107,6 +124,12 @@ dotnet add package Eventual2PC

## 发布历史

### 1.1.0(2020/04/30)

- 1)`ITransactionInitiator`接口增加属性 `CurrentTransactionId``CurrentTransactionType`

- 2)增加事务流转过程中产生的 `Command` 的接口定义

### 1.0.2(2020/4/28)

- 移除异常类 `UnknownTransactionPreparationException`
Expand Down
Binary file added nuget.ico
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务发起方添加已提交的参与方
/// </summary>
public interface ITransactionInitiatorAddCommittedParticipantCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }

/// <summary>
/// 事务类型
/// </summary>
byte TransactionType { get; }

/// <summary>
/// 事务参与方ID
/// </summary>
string ParticipantId { get; }

/// <summary>
/// 事务参与方类型
/// </summary>
byte ParticipantType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务发起方添加预提交失败的参与方
/// </summary>
public interface ITransactionInitiatorAddPreCommitFailedParticipantCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }

/// <summary>
/// 事务类型
/// </summary>
byte TransactionType { get; }

/// <summary>
/// 事务参与方ID
/// </summary>
string ParticipantId { get; }

/// <summary>
/// 事务参与方类型
/// </summary>
byte ParticipantType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务发起方添加预提交成功的参与方
/// </summary>
public interface ITransactionInitiatorAddPreCommitSucceedParticipantCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }

/// <summary>
/// 事务类型
/// </summary>
byte TransactionType { get; }

/// <summary>
/// 事务参与方ID
/// </summary>
string ParticipantId { get; }

/// <summary>
/// 事务参与方类型
/// </summary>
byte ParticipantType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务发起方添加已回滚的参与方
/// </summary>
public interface ITransactionInitiatorAddRolledbackParticipantCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }

/// <summary>
/// 事务类型
/// </summary>
byte TransactionType { get; }

/// <summary>
/// 事务参与方ID
/// </summary>
string ParticipantId { get; }

/// <summary>
/// 事务参与方类型
/// </summary>
byte ParticipantType { get; }
}
}
13 changes: 13 additions & 0 deletions src/Eventual2PC/Commands/ITransactionParticipantCommitCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务参与方提交命令
/// </summary>
public interface ITransactionParticipantCommitCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务参与方预提交命令
/// </summary>
public interface ITransactionParticipantPreCommitCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }

/// <summary>
/// 事务类型
/// </summary>
byte TransactionType { get; }

/// <summary>
/// 事务发起方ID
/// </summary>
string InitiatorId { get; }

/// <summary>
/// 事务发起方类型
/// </summary>
byte InitiatorType { get; }
}
}
13 changes: 13 additions & 0 deletions src/Eventual2PC/Commands/ITransactionParticipantRollbackCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Eventual2PC.Commands
{
/// <summary>
/// 事务参与方回滚命令
/// </summary>
public interface ITransactionParticipantRollbackCommand
{
/// <summary>
/// 事务ID
/// </summary>
string TransactionId { get; }
}
}
7 changes: 4 additions & 3 deletions src/Eventual2PC/Eventual2PC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<RepositoryUrl>https://github.com/berkaroad/Eventual2PC</RepositoryUrl>
<Authors>Jerry Bai</Authors>
<PackageId>Eventual2PC</PackageId>
<Version>1.0.2</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Version>1.1.0</Version>
<AssemblyVersion>1.1.0</AssemblyVersion>
<Title>Eventual2PC</Title>
<Description>最终一致性二阶段提交范式,简化多聚合根之间交互事务的实现。</Description>
<PackageTags>2pc eventual transaction processmanager saga eda cqrs</PackageTags>
<PackageReleaseNotes>移除异常类 `UnknownTransactionPreparationException`
<PackageReleaseNotes>1)`ITransactionInitiator`接口增加属性 `CurrentTransactionId`、`CurrentTransactionType`
2)增加事务流转过程中产生的 `Command` 的接口定义
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
10 changes: 10 additions & 0 deletions src/Eventual2PC/ITransactionInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,15 @@ public interface ITransactionInitiator
/// 是否事务在处理中
/// </summary>
bool IsTransactionProcessing { get; }

/// <summary>
/// 当前事务ID
/// </summary>
string CurrentTransactionId { get; }

/// <summary>
/// 当前事务类型
/// </summary>
byte CurrentTransactionType { get; }
}
}

0 comments on commit 991566b

Please sign in to comment.