Skip to content

Commit

Permalink
v1.1.0; 完善Readme; 其它细节调整;
Browse files Browse the repository at this point in the history
  • Loading branch information
stratosblue committed May 19, 2024
1 parent 35aefb9 commit 1bd4793
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ A message driven distributed asynchronous workflow framework. 消息驱动的分
- 目标框架 `net7.0`+;
- *针对单个消息类型的Qos;

### NOTE:
- 更新包时应当`尽可能``全链路更新`,避免导致的未知问题;
- `WorkflowContext` 核心为 `字符串字典` 其属性在赋值时进行序列化存放,对象后续的修改不会反应到上下文中;

## 3. 开始使用

### 3.1 引用 `FluentWorkflow.Core`
Expand Down Expand Up @@ -264,4 +268,28 @@ services.AddFluentWorkFlow().EnableDiagnostic();

-------

## 6 流程的中止、挂起与恢复

### 6.1 中止流程
`WorkFlow``On*StageAsync``On*StageCompletedAsync` 中不执行参数委托 `fireMessage`,则后续流程不再执行

### 6.2 流程挂起
`WorkFlow``On*StageAsync``On*StageCompletedAsync` 中不执行参数委托 `fireMessage`,中止流程,在此基础上调用 `SerializeContext` 方法将上下文序列化后存放
```C#
// 存放 contextData 以用于流程恢复
var contextData = SerializeContext(message.Context);
```

### 6.3 流程恢复
调用具体 `WorkFlow` 的静态方法 `ResumeAsync` 使用挂起的流程数据进行恢复执行
```C#
// contextData 为序列化的上下文数据
await XXXXWorkflow.ResumeAsync(contextData, serviceProvider, cancellationToken)
```

#### 注意:
恢复流程将会再次调用序列化上下文时的方法,需要注意,小心再次被挂起

-------

更多信息参见源码内的测试代码
2 changes: 1 addition & 1 deletion package.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.0.0</Version>
<Version>1.1.0</Version>

<Description>A message driven distributed asynchronous workflow framework. 消息驱动的分布式异步工作流程处理框架。</Description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class FluentWorkflowServiceCollectionExtensions
#region Public 方法

/// <summary>
///
/// 添加 FluentWorkflow 基础组件
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static string GetChildWorkflowAlias(this IWorkflowContext workflowContext
/// <param name="workflowContext"></param>
/// <param name="alias"></param>
/// <returns></returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetChildWorkflowAlias(this IWorkflowContext workflowContext, string alias)
{
workflowContext.SetValue(FluentWorkflowConstants.ContextKeys.WorkflowAlias, alias);
Expand All @@ -58,6 +59,7 @@ public static bool TryGetChildWorkflowAlias(this IWorkflowContext workflowContex
/// </summary>
/// <param name="workflowContext"></param>
/// <param name="failureStackTrace"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetFailureStackTrace(this IWorkflowContext workflowContext, string? failureStackTrace)
{
workflowContext.SetValue(FluentWorkflowConstants.ContextKeys.FailureStackTrace, failureStackTrace);
Expand All @@ -84,6 +86,7 @@ public static bool TryGetFailureStackTrace(this IWorkflowContext workflowContext
/// </summary>
/// <param name="workflowContext"></param>
/// <param name="failureMessage"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetFailureMessage(this IWorkflowContext workflowContext, string failureMessage)
{
workflowContext.SetValue(FluentWorkflowConstants.ContextKeys.FailureMessage, failureMessage);
Expand Down
5 changes: 4 additions & 1 deletion src/FluentWorkflow.Core/Implement/WorkflowContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentWorkflow.Interface;
using System.ComponentModel;
using FluentWorkflow.Interface;

namespace FluentWorkflow;

Expand Down Expand Up @@ -102,9 +103,11 @@ public WorkflowContext(string id, IEnumerable<KeyValuePair<string, string>> valu
#region Public 方法

/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetCurrentStage(string stage) => DataContainer[FluentWorkflowConstants.ContextKeys.Stage] = CheckBeforeSetCurrentStage(stage);

/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetParent(WorkflowContextMetadata parent)
{
ArgumentNullException.ThrowIfNull(parent);
Expand Down

0 comments on commit 1bd4793

Please sign in to comment.