-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6343 from elsa-workflows/feature/4835
Controlled Commit States Feature Implementation
- Loading branch information
Showing
79 changed files
with
1,166 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Elsa.Workflows; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Extensions; | ||
using Elsa.Workflows.CommitStates.Strategies; | ||
|
||
namespace Elsa.Server.Web; | ||
|
||
public class SampleWorkflow : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder builder) | ||
{ | ||
builder.WorkflowOptions.CommitStrategyName = "Every 10 seconds"; | ||
builder.Root = new Sequence | ||
{ | ||
Activities = | ||
{ | ||
new WriteLine("Commit before executing").SetCommitStrategy(nameof(ExecutingActivityStrategy)), | ||
new WriteLine("Commit after executing").SetCommitStrategy(nameof(ExecutedActivityStrategy)), | ||
new WriteLine("Commit before & after executing").SetCommitStrategy(nameof(CommitAlwaysActivityStrategy)), | ||
new WriteLine("Commit only based on the workflow commit options").SetCommitStrategy(nameof(DefaultActivityStrategy)), | ||
new WriteLine("Never commit the workflow when this activity is about to execute or has executed").SetCommitStrategy(nameof(CommitNeverActivityStrategy)), | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/clients/Elsa.Api.Client/Resources/CommitStrategies/Contracts/IIncidentStrategiesApi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Elsa.Api.Client.Resources.CommitStrategies.Models; | ||
using Elsa.Api.Client.Shared.Models; | ||
using Refit; | ||
|
||
namespace Elsa.Api.Client.Resources.CommitStrategies.Contracts; | ||
|
||
/// <summary> | ||
/// Represents a client for the commit strategies API. | ||
/// </summary> | ||
public interface ICommitStrategiesApi | ||
{ | ||
/// <summary> | ||
/// Lists workflow commit strategies. | ||
/// </summary> | ||
/// <returns>A list response containing activity commit strategy descriptors and their count.</returns> | ||
[Get("/descriptors/commit-strategies/workflows")] | ||
Task<ListResponse<CommitStrategyDescriptor>> ListWorkflowStrategiesAsync(CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Lists activity commit strategies. | ||
/// </summary> | ||
/// <returns>A list response containing activity commit strategy descriptors and their count.</returns> | ||
[Get("/descriptors/commit-strategies/activities")] | ||
Task<ListResponse<CommitStrategyDescriptor>> ListActivityStrategiesAsync(CancellationToken cancellationToken = default); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/clients/Elsa.Api.Client/Resources/CommitStrategies/Models/CommitStrategyDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Elsa.Api.Client.Resources.CommitStrategies.Models; | ||
|
||
/// <summary> | ||
/// Represents a descriptor for a commit strategy, containing information such as its technical name, | ||
/// display name, and description. | ||
/// </summary> | ||
public record CommitStrategyDescriptor(string Name, string DisplayName, string Description); |
19 changes: 19 additions & 0 deletions
19
...lients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowCommitStateOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models; | ||
|
||
public class WorkflowCommitStateOptions | ||
{ | ||
/// <summary> | ||
/// Commit workflow state before the workflow starts. | ||
/// </summary> | ||
public bool Starting { get; set; } | ||
|
||
/// <summary> | ||
/// Commit workflow state before an activity executes, unless the activity is configured to not commit state. | ||
/// </summary> | ||
public bool ActivityExecuting { get; set; } | ||
|
||
/// <summary> | ||
/// Commit workflow state after an activity executes, unless the activity is configured to not commit state. | ||
/// </summary> | ||
public bool ActivityExecuted { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.