Merge pull request #6418 from elsa-workflows/enh/disable-bg-jobs-blueberry

Add toggle for WorkflowInboxCleanupJob in WorkflowRuntimeFeature
This commit is contained in:
Sipke Schoorstra 2025-02-18 15:54:55 +01:00 committed by GitHub
commit 548272fb01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 8 deletions

View file

@ -5,6 +5,7 @@ on:
branches:
- 'blueberry'
- 'feature/*'
- 'enh/*'
release:
types: [ prereleased, published ]
env:

View file

@ -29,12 +29,9 @@ namespace Elsa.Workflows.Runtime.Features;
/// Installs and configures workflow runtime features.
/// </summary>
[DependsOn(typeof(SystemClockFeature))]
public class WorkflowRuntimeFeature : FeatureBase
public class WorkflowRuntimeFeature(IModule module) : FeatureBase(module)
{
/// <inheritdoc />
public WorkflowRuntimeFeature(IModule module) : base(module)
{
}
private bool _enableWorkflowInboxCleanupJob = true;
private IDictionary<string, DispatcherChannel> WorkflowDispatcherChannels { get; set; } = new Dictionary<string, DispatcherChannel>();
@ -126,12 +123,30 @@ public class WorkflowRuntimeFeature : FeatureBase
/// A delegate to configure the <see cref="WorkflowInboxCleanupOptions"/>.
/// </summary>
public Action<WorkflowInboxCleanupOptions> WorkflowInboxCleanupOptions { get; set; } = _ => { };
/// <summary>
/// A delegate to configure the <see cref="WorkflowDispatcherOptions"/>.
/// </summary>
public Action<WorkflowDispatcherOptions> WorkflowDispatcherOptions { get; set; } = _ => { };
/// <summary>
/// Enables the workflow inbox cleanup job.
/// </summary>
public WorkflowRuntimeFeature EnableWorkflowInboxCleanupJob()
{
_enableWorkflowInboxCleanupJob = true;
return this;
}
/// <summary>
/// Disables the workflow inbox cleanup job.
/// </summary>
public WorkflowRuntimeFeature DisableWorkflowInboxCleanupJob()
{
_enableWorkflowInboxCleanupJob = false;
return this;
}
/// <summary>
/// Register the specified workflow type.
/// </summary>
@ -188,7 +203,7 @@ public class WorkflowRuntimeFeature : FeatureBase
public override void ConfigureHostedServices()
{
Module.ConfigureHostedService<PopulateRegistriesHostedService>();
Module.ConfigureHostedService<WorkflowInboxCleanupHostedService>();
if (_enableWorkflowInboxCleanupJob) Module.ConfigureHostedService<WorkflowInboxCleanupHostedService>();
}
/// <inheritdoc />
@ -240,7 +255,7 @@ public class WorkflowRuntimeFeature : FeatureBase
.AddScoped<IWorkflowCancellationService, WorkflowCancellationService>()
.AddScoped<ILogRecordExtractor<ActivityExecutionRecord>, ActivityExecutionRecordExtractor>()
.AddScoped<ILogRecordExtractor<WorkflowExecutionLogRecord>, WorkflowExecutionLogRecordExtractor>()
// Stores.
.AddScoped(BookmarkStore)
.AddScoped(TriggerStore)