diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs index 0f84f93a6..06be22263 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs @@ -33,6 +33,6 @@ public class EFCoreWorkflowManagementPersistenceFeature : PersistenceFeatureBase base.Apply(); AddStore(); - AddStore(); + AddStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/Extensions.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/Extensions.cs index 42805a759..40beb7b49 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/Extensions.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/Extensions.cs @@ -1,6 +1,4 @@ using Elsa.Workflows.Runtime.Features; -using Elsa.Workflows.Runtime.Implementations; -using Microsoft.Extensions.DependencyInjection; namespace Elsa.EntityFrameworkCore.Modules.Runtime; @@ -26,13 +24,4 @@ public static class Extensions feature.Module.Configure(configure); return feature; } - - /// - /// Configures the workflow runtime to send workflow state to the . - /// - public static WorkflowRuntimeFeature UseAsyncWorkflowStateExporter(this WorkflowRuntimeFeature feature) - { - feature.WorkflowStateExporter = sp => ActivatorUtilities.CreateInstance(sp); - return feature; - } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs b/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs index 9fc1782a0..0c089e079 100644 --- a/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs +++ b/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs @@ -29,6 +29,7 @@ namespace Elsa.Workflows.Management.Features; [DependsOn(typeof(MediatorFeature))] [DependsOn(typeof(SystemClockFeature))] [DependsOn(typeof(WorkflowsFeature))] +[DependsOn(typeof(WorkflowDefinitionsFeature))] public class WorkflowManagementFeature : FeatureBase { private const string PrimitivesCategory = "Primitives"; diff --git a/src/modules/Elsa.Workflows.Runtime/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Workflows.Runtime/Extensions/ModuleExtensions.cs index 42d09d2cc..3a95c04ce 100644 --- a/src/modules/Elsa.Workflows.Runtime/Extensions/ModuleExtensions.cs +++ b/src/modules/Elsa.Workflows.Runtime/Extensions/ModuleExtensions.cs @@ -39,4 +39,10 @@ public static class ModuleExtensions feature.Module.Configure(configure); return feature; } + + public static WorkflowRuntimeFeature UseAsyncWorkflowStateExporter(this WorkflowRuntimeFeature feature, Action? configure = default) + { + feature.Module.Configure(configure); + return feature; + } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Features/AsyncWorkflowStateExporterFeature.cs b/src/modules/Elsa.Workflows.Runtime/Features/AsyncWorkflowStateExporterFeature.cs new file mode 100644 index 000000000..a38e7f300 --- /dev/null +++ b/src/modules/Elsa.Workflows.Runtime/Features/AsyncWorkflowStateExporterFeature.cs @@ -0,0 +1,26 @@ +using Elsa.Features.Abstractions; +using Elsa.Features.Attributes; +using Elsa.Features.Services; +using Elsa.Workflows.Management.Features; +using Elsa.Workflows.Runtime.Implementations; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Workflows.Runtime.Features; + +/// +/// Configures and enables . +/// +[DependsOn(typeof(WorkflowInstancesFeature))] +public class AsyncWorkflowStateExporterFeature : FeatureBase +{ + /// + public AsyncWorkflowStateExporterFeature(IModule module) : base(module) + { + } + + /// + public override void Configure() + { + Module.Configure(workflowRuntime => workflowRuntime.WorkflowStateExporter = sp => ActivatorUtilities.CreateInstance(sp)); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs b/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs index b2de895d1..8ceefaee4 100644 --- a/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs +++ b/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs @@ -72,7 +72,7 @@ public class WorkflowRuntimeFeature : FeatureBase /// /// A factory that instantiates an . /// - public Func WorkflowStateExporter { get; set; } = sp => sp.GetRequiredService(); + public Func WorkflowStateExporter { get; set; } = ActivatorUtilities.GetServiceOrCreateInstance; /// /// A factory that instantiates an . @@ -145,8 +145,6 @@ public class WorkflowRuntimeFeature : FeatureBase .AddWorkflowDefinitionProvider() // Workflow state exporter. - .AddSingleton() - .AddSingleton() .AddSingleton(WorkflowStateExporter) // Domain handlers. diff --git a/src/samples/aspnet/Elsa.Samples.TelnyxIntegration/Program.cs b/src/samples/aspnet/Elsa.Samples.TelnyxIntegration/Program.cs index eee300b04..024e942f2 100644 --- a/src/samples/aspnet/Elsa.Samples.TelnyxIntegration/Program.cs +++ b/src/samples/aspnet/Elsa.Samples.TelnyxIntegration/Program.cs @@ -63,7 +63,7 @@ services runtime.UseDefaultRuntime(dr => dr.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))); runtime.UseExecutionLogRecords(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite())); runtime.UseExecutionLogRecords(e => e.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))); - runtime.WorkflowStateExporter = sp => sp.GetRequiredService(); + runtime.UseAsyncWorkflowStateExporter(); }) .UseActivityDefinitions(feature => feature.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))) .UseJobs(jobs => jobs.ConfigureOptions = options => options.WorkerCount = 10)