-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement pluggable storage for activity input and output properties
- Loading branch information
1 parent
6a49f7a
commit 332741d
Showing
65 changed files
with
1,922 additions
and
331 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elsa.Providers.WorkflowStorage; | ||
using Elsa.Services.Models; | ||
using Elsa.Services.WorkflowStorage; | ||
|
||
namespace Elsa.ActivityResults | ||
{ | ||
public class OutputResult : ActivityExecutionResult | ||
{ | ||
public OutputResult(object? output, string? storageName = default) | ||
public OutputResult(object? output, string? storageProviderName = default) | ||
{ | ||
Output = output; | ||
StorageName = storageName; | ||
StorageProviderName = storageProviderName; | ||
} | ||
|
||
public object? Output { get; } | ||
public string? StorageName { get; } | ||
public string? StorageProviderName { get; } | ||
|
||
public override async ValueTask ExecuteAsync(ActivityExecutionContext activityExecutionContext, CancellationToken cancellationToken) | ||
{ | ||
var workflowStorageService = activityExecutionContext.GetService<IWorkflowStorageService>(); | ||
var provider = workflowStorageService.GetProviderByNameOrDefault(StorageName); | ||
await provider.SaveAsync(activityExecutionContext, ActivityOutput.PropertyName, Output, cancellationToken); | ||
var workflowStorageContext = new WorkflowStorageContext(activityExecutionContext.WorkflowInstance, activityExecutionContext.ActivityId); | ||
await workflowStorageService.SaveAsync(StorageProviderName, workflowStorageContext, ActivityOutput.PropertyName, Output, cancellationToken); | ||
activityExecutionContext.WorkflowInstance.Output = new WorkflowOutputReference(StorageProviderName, workflowStorageContext.ActivityId); | ||
} | ||
} | ||
} |
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
9 changes: 0 additions & 9 deletions
9
src/core/Elsa.Abstractions/Extensions/ActivityExecutionContextExtensions.cs
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
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
6 changes: 6 additions & 0 deletions
6
src/core/Elsa.Abstractions/Providers/WorkflowStorage/WorkflowStorageContext.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,6 @@ | ||
using Elsa.Models; | ||
|
||
namespace Elsa.Providers.WorkflowStorage | ||
{ | ||
public record WorkflowStorageContext(WorkflowInstance WorkflowInstance, string ActivityId); | ||
} |
9 changes: 4 additions & 5 deletions
9
src/core/Elsa.Abstractions/Providers/WorkflowStorage/WorkflowStorageProvider.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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elsa.Services.Models; | ||
|
||
namespace Elsa.Providers.WorkflowStorage | ||
{ | ||
public abstract class WorkflowStorageProvider : IWorkflowStorageProvider | ||
{ | ||
public string Name => GetType().Name.Replace("WorkflowStorageProvider", ""); | ||
public string DisplayName => Name; | ||
public abstract ValueTask SaveAsync(ActivityExecutionContext context, string propertyName, object? value, CancellationToken cancellationToken = default); | ||
public abstract ValueTask<object?> LoadAsync(ActivityExecutionContext context, string propertyName, CancellationToken cancellationToken = default); | ||
public abstract ValueTask DeleteAsync(ActivityExecutionContext context, string propertyName, CancellationToken cancellationToken = default); | ||
public abstract ValueTask DeleteAsync(ActivityExecutionContext context, CancellationToken cancellationToken = default); | ||
public abstract ValueTask SaveAsync(WorkflowStorageContext context, string key, object? value, CancellationToken cancellationToken = default); | ||
public abstract ValueTask<object?> LoadAsync(WorkflowStorageContext context, string key, CancellationToken cancellationToken = default); | ||
public abstract ValueTask DeleteAsync(WorkflowStorageContext context, string key, CancellationToken cancellationToken = default); | ||
public abstract ValueTask DeleteAsync(WorkflowStorageContext context, CancellationToken cancellationToken = default); | ||
} | ||
} |
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
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.