Refactor workflow runtime structure and update handlers.

Moved `CancelWorkflowsCommandHandler` to the shared runtime module. Updated related project references, features, and configurations accordingly. Improved `WorkflowInstance` actor to save state using `IWorkflowInstanceManager`.
This commit is contained in:
Sipke Schoorstra 2025-01-02 11:43:21 +01:00
parent be68b4c33f
commit 5e2644f751
7 changed files with 11 additions and 15 deletions

View file

@ -74,7 +74,7 @@ const bool useAzureServiceBus = false;
const bool useKafka = false;
const bool useReadOnlyMode = false;
const bool useSignalR = false; // Disabled until Elsa Studio sends authenticated requests.
const WorkflowRuntime workflowRuntime = WorkflowRuntime.Distributed;
const WorkflowRuntime workflowRuntime = WorkflowRuntime.ProtoActor;
const DistributedCachingTransport distributedCachingTransport = DistributedCachingTransport.MassTransit;
const MassTransitBroker massTransitBroker = MassTransitBroker.Memory;
const bool useMultitenancy = false;

View file

@ -18,4 +18,8 @@
<ProjectReference Include="..\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Handlers\" />
</ItemGroup>
</Project>

View file

@ -2,8 +2,8 @@ using Elsa.Extensions;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Workflows.Runtime.Distributed.Handlers;
using Elsa.Workflows.Runtime.Features;
using Elsa.Workflows.Runtime.Handlers;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Workflows.Runtime.Distributed.Features;

View file

@ -211,6 +211,8 @@ internal class WorkflowInstance(
var workflowRunner = scope.ServiceProvider.GetRequiredService<IWorkflowRunner>();
var workflowResult = await workflowRunner.RunAsync(WorkflowGraph, WorkflowState, runWorkflowOptions, _linkedCancellationToken);
WorkflowState = workflowResult.WorkflowState;
var workflowInstanceManager = scope.ServiceProvider.GetRequiredService<IWorkflowInstanceManager>();
await workflowInstanceManager.SaveAsync(WorkflowState, Context.CancellationToken);
return workflowResult;
}

View file

@ -8,15 +8,4 @@ namespace Elsa.Workflows.Runtime.Features;
/// Installs the default runtime services.
/// </summary>
[DependsOn(typeof(WorkflowRuntimeFeature))]
public class DefaultWorkflowRuntimeFeature : FeatureBase
{
/// <inheritdoc />
public DefaultWorkflowRuntimeFeature(IModule module) : base(module)
{
}
/// <inheritdoc />
public override void Apply()
{
}
}
public class DefaultWorkflowRuntimeFeature(IModule module) : FeatureBase(module);

View file

@ -310,6 +310,7 @@ public class WorkflowRuntimeFeature : FeatureBase
// Domain handlers.
.AddCommandHandler<DispatchWorkflowCommandHandler>()
.AddCommandHandler<CancelWorkflowsCommandHandler>()
.AddNotificationHandler<ResumeDispatchWorkflowActivity>()
.AddNotificationHandler<ResumeBulkDispatchWorkflowActivity>()
.AddNotificationHandler<ResumeExecuteWorkflowActivity>()

View file

@ -2,7 +2,7 @@ using Elsa.Mediator.Contracts;
using Elsa.Mediator.Models;
using Elsa.Workflows.Runtime.Commands;
namespace Elsa.Workflows.Runtime.Distributed.Handlers;
namespace Elsa.Workflows.Runtime.Handlers;
/// <summary>
/// Handles the <see cref="CancelWorkflowsCommand"/>.