This commit is contained in:
Sipke Schoorstra 2022-12-22 20:23:18 +01:00
parent bbe8ee34c0
commit a17bbbc112
6 changed files with 45 additions and 19 deletions

View file

@ -22,14 +22,14 @@
</ItemGroup>
<ItemGroup Label="ProtoActor">
<PackageReference Include="Proto.Actor" Version="0.33.0" />
<PackageReference Include="Proto.Cluster" Version="0.33.0" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="0.33.0" />
<PackageReference Include="Proto.Cluster.Consul" Version="0.33.0" />
<PackageReference Include="Proto.Cluster.Identity.Redis" Version="0.33.0" />
<PackageReference Include="Proto.Cluster.TestProvider" Version="0.33.0" />
<PackageReference Include="Proto.Persistence" Version="0.33.0" />
<PackageReference Include="Proto.Remote" Version="0.33.0" />
<PackageReference Include="Proto.Actor" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Cluster" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Cluster.Consul" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Cluster.Identity.Redis" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Cluster.TestProvider" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Persistence" Version="1.0.0-rc5.4" />
<PackageReference Include="Proto.Remote" Version="1.0.0-rc5.4" />
</ItemGroup>
<ItemGroup>

View file

@ -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)

View file

@ -20,9 +20,13 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Workflows.Runtime.Features;
/// <summary>
/// Installs and configures workflow runtime features.
/// </summary>
[DependsOn(typeof(SystemClockFeature))]
public class WorkflowRuntimeFeature : FeatureBase
{
/// <inheritdoc />
public WorkflowRuntimeFeature(IModule module) : base(module)
{
}
@ -34,7 +38,7 @@ public class WorkflowRuntimeFeature : FeatureBase
/// <summary>
/// A factory that instantiates a concrete <see cref="IWorkflowInvoker"/>.
/// A factory that instantiates a concrete <see cref="IWorkflowRuntime"/>.
/// </summary>
public Func<IServiceProvider, IWorkflowRuntime> WorkflowRuntime { get; set; } = sp => ActivatorUtilities.CreateInstance<DefaultWorkflowRuntime>(sp);
@ -55,11 +59,13 @@ public class WorkflowRuntimeFeature : FeatureBase
public Func<IServiceProvider, ITriggerStore> WorkflowTriggerStore { get; set; } = sp => sp.GetRequiredService<MemoryTriggerStore>();
public Func<IServiceProvider, IWorkflowExecutionLogStore> WorkflowExecutionLogStore { get; set; } = sp => sp.GetRequiredService<MemoryWorkflowExecutionLogStore>();
public Func<IServiceProvider, IDistributedLockProvider> DistributedLockProvider { get; set; } = _ =>
new FileDistributedSynchronizationProvider(new DirectoryInfo( Path.Combine(Environment.CurrentDirectory, "App_Data/locks")));
public Func<IServiceProvider, IDistributedLockProvider> DistributedLockProvider { get; set; } = _ => new FileDistributedSynchronizationProvider(new DirectoryInfo( Path.Combine(Environment.CurrentDirectory, "App_Data/locks")));
public Func<IServiceProvider, IWorkflowStateExporter> WorkflowStateExporter { get; set; } = sp => sp.GetRequiredService<NoopWorkflowStateExporter>();
public Func<IServiceProvider, IWorkflowStateExporter> WorkflowStateExporter { get; set; } =
sp => sp.GetRequiredService<NoopWorkflowStateExporter>();
/// <summary>
/// A delegate to configure the <see cref="DistributedLockingOptions"/>.
/// </summary>
public Action<DistributedLockingOptions> DistributedLockingOptions { get; set; } = _ => { };
/// <summary>
/// Register the specified workflow type.
@ -80,6 +86,9 @@ public class WorkflowRuntimeFeature : FeatureBase
/// <inheritdoc />
public override void Apply()
{
// Options.
Services.Configure(DistributedLockingOptions);
Services
// Core.
.AddSingleton<ITriggerIndexer, TriggerIndexer>()
@ -114,12 +123,12 @@ public class WorkflowRuntimeFeature : FeatureBase
.AddNotificationHandlersFrom<WorkflowRuntimeFeature>()
.AddCommandHandlersFrom<WorkflowRuntimeFeature>()
// Instantiation strategies.
// Workflow activation strategies.
.AddSingleton<IWorkflowActivationStrategy, SingletonStrategy>()
.AddSingleton<IWorkflowActivationStrategy, CorrelatedSingletonStrategy>()
.AddSingleton<IWorkflowActivationStrategy, CorrelationStrategy>()
;
Services.Configure<WorkflowRuntimeOptions>(options => { options.Workflows = Workflows; });
Services.Configure<RuntimeOptions>(options => { options.Workflows = Workflows; });
}
}

View file

@ -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<WorkflowRuntimeOptions> options,
IOptions<RuntimeOptions> options,
IIdentityGraphService identityGraphService,
IWorkflowBuilderFactory workflowBuilderFactory,
SerializerOptionsProvider serializerOptionsProvider,

View file

@ -0,0 +1,14 @@
using Elsa.Workflows.Runtime.Implementations;
namespace Elsa.Workflows.Runtime.Options;
/// <summary>
/// Provides options related to distributed locking, which is used by <see cref="DefaultWorkflowRuntime"/>.
/// </summary>
public class DistributedLockingOptions
{
/// <summary>
/// The maximum amount of time to wait before giving up trying to acquire a lock. Defaults to 10 minutes.
/// </summary>
public TimeSpan LockAcquisitionTimeout { get; set; } = TimeSpan.FromMinutes(10);
}

View file

@ -2,7 +2,10 @@ using Elsa.Workflows.Core.Services;
namespace Elsa.Workflows.Runtime.Options;
public class WorkflowRuntimeOptions
/// <summary>
/// Provides options to the workflow runtime.
/// </summary>
public class RuntimeOptions
{
/// <summary>
/// A list of workflow builders configured during application startup.