-
Notifications
You must be signed in to change notification settings - Fork 1
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 #7 from LittleLittleCloud/u/fix#1
refactor over workflow engine
- Loading branch information
Showing
15 changed files
with
654 additions
and
376 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace StepWise.Core.Extension; | ||
|
||
public static class StepWiseEngineExtension | ||
{ | ||
/// <summary> | ||
/// Execute the workflow until the target step is reached or no further steps can be executed. | ||
/// If the <paramref name="earlyStop"/> is true, the workflow will stop as soon as the target step is reached and completed. | ||
/// Otherwise, the workflow will continue to execute until no further steps can be executed. | ||
/// </summary> | ||
public static async Task<TResult> ExecuteAsync<TResult>( | ||
this IStepWiseEngine engine, | ||
string targetStepName, | ||
Dictionary<string, StepVariable>? inputs = null, | ||
bool earlyStop = true, | ||
int? maxSteps = null, | ||
CancellationToken ct = default) | ||
{ | ||
maxSteps ??= int.MaxValue; | ||
await foreach (var stepResult in engine.ExecuteAsync(targetStepName, inputs, earlyStop, maxSteps, ct)) | ||
{ | ||
if (stepResult.Result != null && stepResult.StepName == targetStepName) | ||
{ | ||
return stepResult.Result.As<TResult>() ?? throw new Exception($"Step '{targetStepName}' did not return the expected result type."); | ||
} | ||
} | ||
|
||
throw new Exception($"Step '{targetStepName}' did not return the expected result type."); | ||
} | ||
} |
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,16 @@ | ||
| ||
namespace StepWise.Core; | ||
|
||
public interface IStepWiseEngine | ||
{ | ||
/// <summary> | ||
/// Execute the workflow until the target step is reached or no further steps can be executed. | ||
/// If the <paramref name="earlyStop"/> is true, the workflow will stop as soon as the target step is reached and completed. | ||
/// Otherwise, the workflow will continue to execute until no further steps can be executed. | ||
IAsyncEnumerable<StepResult> ExecuteAsync( | ||
string targetStep, | ||
Dictionary<string, StepVariable>? inputs = null, | ||
bool earlyStop = true, | ||
int? maxSteps = null, | ||
CancellationToken ct = default); | ||
} |
This file was deleted.
Oops, something went wrong.
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.