From a17bbbc112554192217fbadb42b59bb089c9e1b2 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 22 Dec 2022 20:23:18 +0100 Subject: [PATCH] Stash --- .../Elsa.ProtoActor/Elsa.ProtoActor.csproj | 16 ++++++------- .../Features/ProtoActorFeature.cs | 2 +- .../Features/WorkflowRuntimeFeature.cs | 23 +++++++++++++------ .../ClrWorkflowDefinitionProvider.cs | 4 ++-- .../Options/DistributedLockingOptions.cs | 14 +++++++++++ ...lowRuntimeOptions.cs => RuntimeOptions.cs} | 5 +++- 6 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 src/modules/Elsa.Workflows.Runtime/Options/DistributedLockingOptions.cs rename src/modules/Elsa.Workflows.Runtime/Options/{WorkflowRuntimeOptions.cs => RuntimeOptions.cs} (78%) diff --git a/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj b/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj index ac21981ee..4d7324214 100644 --- a/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj +++ b/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj @@ -22,14 +22,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/modules/Elsa.ProtoActor/Features/ProtoActorFeature.cs b/src/modules/Elsa.ProtoActor/Features/ProtoActorFeature.cs index 8cc6ed650..fbbce1d3d 100644 --- a/src/modules/Elsa.ProtoActor/Features/ProtoActorFeature.cs +++ b/src/modules/Elsa.ProtoActor/Features/ProtoActorFeature.cs @@ -98,7 +98,7 @@ public class ProtoActorFeature : FeatureBase .WithHeartbeatExpiration(TimeSpan.FromDays(1)) .WithActorRequestTimeout(TimeSpan.FromHours(1)) .WithActorActivationTimeout(TimeSpan.FromHours(1)) - .WithActorSpawnTimeout(TimeSpan.FromHours(1)) + .WithActorSpawnVerificationTimeout(TimeSpan.FromHours(1)) .WithClusterKind(WorkflowGrainActor.Kind, workflowGrainProps) .WithClusterKind(BookmarkGrainActor.Kind, bookmarkGrainProps) .WithClusterKind(RunningWorkflowsGrainActor.Kind, workflowRegistryGrainProps) diff --git a/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs b/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs index 8382566d3..7b1ca3127 100644 --- a/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs +++ b/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs @@ -20,9 +20,13 @@ using Microsoft.Extensions.DependencyInjection; namespace Elsa.Workflows.Runtime.Features; +/// +/// Installs and configures workflow runtime features. +/// [DependsOn(typeof(SystemClockFeature))] public class WorkflowRuntimeFeature : FeatureBase { + /// public WorkflowRuntimeFeature(IModule module) : base(module) { } @@ -34,7 +38,7 @@ public class WorkflowRuntimeFeature : FeatureBase /// - /// A factory that instantiates a concrete . + /// A factory that instantiates a concrete . /// public Func WorkflowRuntime { get; set; } = sp => ActivatorUtilities.CreateInstance(sp); @@ -55,11 +59,13 @@ public class WorkflowRuntimeFeature : FeatureBase public Func WorkflowTriggerStore { get; set; } = sp => sp.GetRequiredService(); public Func WorkflowExecutionLogStore { get; set; } = sp => sp.GetRequiredService(); - public Func DistributedLockProvider { get; set; } = _ => - new FileDistributedSynchronizationProvider(new DirectoryInfo( Path.Combine(Environment.CurrentDirectory, "App_Data/locks"))); + public Func DistributedLockProvider { get; set; } = _ => new FileDistributedSynchronizationProvider(new DirectoryInfo( Path.Combine(Environment.CurrentDirectory, "App_Data/locks"))); + public Func WorkflowStateExporter { get; set; } = sp => sp.GetRequiredService(); - public Func WorkflowStateExporter { get; set; } = - sp => sp.GetRequiredService(); + /// + /// A delegate to configure the . + /// + public Action DistributedLockingOptions { get; set; } = _ => { }; /// /// Register the specified workflow type. @@ -80,6 +86,9 @@ public class WorkflowRuntimeFeature : FeatureBase /// public override void Apply() { + // Options. + Services.Configure(DistributedLockingOptions); + Services // Core. .AddSingleton() @@ -114,12 +123,12 @@ public class WorkflowRuntimeFeature : FeatureBase .AddNotificationHandlersFrom() .AddCommandHandlersFrom() - // Instantiation strategies. + // Workflow activation strategies. .AddSingleton() .AddSingleton() .AddSingleton() ; - Services.Configure(options => { options.Workflows = Workflows; }); + Services.Configure(options => { options.Workflows = Workflows; }); } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Implementations/ClrWorkflowDefinitionProvider.cs b/src/modules/Elsa.Workflows.Runtime/Implementations/ClrWorkflowDefinitionProvider.cs index 08f1a276f..4d248bbfa 100644 --- a/src/modules/Elsa.Workflows.Runtime/Implementations/ClrWorkflowDefinitionProvider.cs +++ b/src/modules/Elsa.Workflows.Runtime/Implementations/ClrWorkflowDefinitionProvider.cs @@ -21,10 +21,10 @@ public class ClrWorkflowDefinitionProvider : IWorkflowDefinitionProvider private readonly SerializerOptionsProvider _serializerOptionsProvider; private readonly ISystemClock _systemClock; private readonly IServiceProvider _serviceProvider; - private readonly WorkflowRuntimeOptions _options; + private readonly RuntimeOptions _options; public ClrWorkflowDefinitionProvider( - IOptions options, + IOptions options, IIdentityGraphService identityGraphService, IWorkflowBuilderFactory workflowBuilderFactory, SerializerOptionsProvider serializerOptionsProvider, diff --git a/src/modules/Elsa.Workflows.Runtime/Options/DistributedLockingOptions.cs b/src/modules/Elsa.Workflows.Runtime/Options/DistributedLockingOptions.cs new file mode 100644 index 000000000..295611f5b --- /dev/null +++ b/src/modules/Elsa.Workflows.Runtime/Options/DistributedLockingOptions.cs @@ -0,0 +1,14 @@ +using Elsa.Workflows.Runtime.Implementations; + +namespace Elsa.Workflows.Runtime.Options; + +/// +/// Provides options related to distributed locking, which is used by . +/// +public class DistributedLockingOptions +{ + /// + /// The maximum amount of time to wait before giving up trying to acquire a lock. Defaults to 10 minutes. + /// + public TimeSpan LockAcquisitionTimeout { get; set; } = TimeSpan.FromMinutes(10); +} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Options/WorkflowRuntimeOptions.cs b/src/modules/Elsa.Workflows.Runtime/Options/RuntimeOptions.cs similarity index 78% rename from src/modules/Elsa.Workflows.Runtime/Options/WorkflowRuntimeOptions.cs rename to src/modules/Elsa.Workflows.Runtime/Options/RuntimeOptions.cs index 639c5d2e5..72b65b06c 100644 --- a/src/modules/Elsa.Workflows.Runtime/Options/WorkflowRuntimeOptions.cs +++ b/src/modules/Elsa.Workflows.Runtime/Options/RuntimeOptions.cs @@ -2,7 +2,10 @@ using Elsa.Workflows.Core.Services; namespace Elsa.Workflows.Runtime.Options; -public class WorkflowRuntimeOptions +/// +/// Provides options to the workflow runtime. +/// +public class RuntimeOptions { /// /// A list of workflow builders configured during application startup.