elsa-core/src/clients/Elsa.Api.Client/Shared/Enums/MergeMode.cs
Sipke Schoorstra 730c01d9b0
Refactors and clarifies Flowchart merge modes (#6993)
* Refactors and clarifies Flowchart merge modes

Improves the clarity and functionality of Flowchart merge modes by:

- Renaming `None` to `Stream` for opportunistic execution.
- Introducing `Merge` for waiting on activated branches only.
- Enhancing `Converge` to be the strictest mode, requiring all inbound connections.
- Providing more detailed descriptions for each mode, emphasizing their behavior and use cases in flow-based terminology.
- Updates default merge mode to Stream

This provides better control over synchronization and execution behavior in workflows.

* Refactor `ActivityExtensions` to improve formatting, fix indentation, and align comments for improved readability and consistency

* Update flowchart tests: replace `SetMergeMode(MergeMode.None)` with `SetMergeMode(null)` and remove unused `Elsa.Workflows` imports.

* Restore None value for Flowchart MergeMode enum (#7107)

* Initial plan

* Add None value to MergeMode enum for backward compatibility

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Fix API client GetMergeMode to maintain non-nullable return type

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* [WIP] Address feedback on flowchart merge modes refactor (#7106)

* Initial plan

* Fix misleading documentation for Merge mode to match actual implementation

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/JoinBehaviors/ForkDecisionJoinTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/JoinBehaviors/ForkDecisionJoinTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test scenarios for implicit join behavior in `ForkDecisionJoinTests`. Updated file references for merge and stream join modes.

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-25 21:06:00 +01:00

52 lines
2 KiB
C#

namespace Elsa.Api.Client.Shared.Enums;
/// <summary>
/// Specifies the strategy for handling multiple inbound execution paths in a workflow.
/// Uses flow-based terminology to describe merge behavior.
/// </summary>
public enum MergeMode
{
/// <summary>
/// No merge mode set. Treated as if merge mode was not specified (null).
/// Provides backward compatibility for existing workflows.
/// Defaults to Stream behavior at runtime.
/// </summary>
None,
/// <summary>
/// Flows freely when possible, ignoring dead/untaken paths.
/// Opportunistic execution based on upstream completion.
/// Uses approximation that proceeds after all upstream sources complete.
/// Suitable for flexible, unstructured merges where optional branches shouldn't block.
/// </summary>
Stream,
/// <summary>
/// Merges only the activated/flowing inbound branches.
/// Waits for all branches that received tokens, ignoring unactivated ones.
/// Use for synchronization points where only taken paths matter (e.g., fork-joins with conditions).
/// </summary>
Merge,
/// <summary>
/// Converges all inbound paths, requiring every connection to execute.
/// Blocks until all branches complete, including unactivated ones.
/// Strictest mode - will block on dead/untaken paths.
/// Use when every single inbound path must execute before proceeding.
/// </summary>
Converge,
/// <summary>
/// Cascades execution for each arriving token independently.
/// Allows multiple concurrent executions (one per arriving token).
/// Use for streaming scenarios where each branch should trigger separate processing.
/// </summary>
Cascade,
/// <summary>
/// Races inbound branches, executing on first arrival and blocking others.
/// Schedule on the first arriving token, block or cancel others.
/// Use for competitive scenarios where only the first result matters.
/// </summary>
Race
}