Added missing functionalities from main as part of the blueberry merge

This commit is contained in:
Marius Vasile Vușcan 2025-03-12 13:34:57 +02:00
parent bb4d3d146c
commit c2161d057a
No known key found for this signature in database
GPG key ID: E0EC75631D902E06
4 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,6 @@
namespace Elsa.Api.Client.Resources.Alterations.Models;
/// <summary>
/// Cancels the workflow instances in an alteration plan.
/// </summary>
public class Cancel : AlterationBase;

View file

@ -154,6 +154,15 @@ public class WorkflowRuntimeFeature(IModule module) : FeatureBase(module)
Services.Configure<WorkflowInboxCleanupOptions>(options => { options.IsEnabled = false; });
return this;
}
/// <summary>
/// Disables the purge bookmark queue recurring task.
/// </summary>
public WorkflowRuntimeFeature DisablePurgeBookmarkQueueRecurringTask()
{
Services.Configure<BookmarkQueuePurgeOptions>(options => { options.IsEnabled = false; });
return this;
}
/// <summary>
/// Register the specified workflow type.
@ -312,7 +321,7 @@ public class WorkflowRuntimeFeature(IModule module) : FeatureBase(module)
.AddRecurringTask<TriggerBookmarkQueueRecurringTask>(TimeSpan.FromMinutes(1))
.AddRecurringTask<PurgeBookmarkQueueRecurringTask>(TimeSpan.FromSeconds(10))
.AddRecurringTask<RestartInterruptedWorkflowsTask>(TimeSpan.FromMinutes(5)) // Same default as the workflow liveness threshold.
// Distributed locking.
.AddSingleton(DistributedLockProvider)

View file

@ -14,4 +14,9 @@ public class BookmarkQueuePurgeOptions
/// The number of records to clean up per sweep.
/// </summary>
public int BatchSize { get; set; } = 1000;
/// <summary>
/// Whether the bookmark queue purge is enabled.
/// </summary>
public bool IsEnabled { get; set; } = true;
}

View file

@ -15,6 +15,12 @@ public class DefaultBookmarkQueuePurger(IBookmarkQueueStore store, ISystemClock
{
public async Task PurgeAsync(CancellationToken cancellationToken = default)
{
if (!options.Value.IsEnabled)
{
logger.LogInformation("Purging bookmark queue is disabled");
return;
}
var currentPage = 0;
var now = systemClock.UtcNow;
var thresholdDate = now - options.Value.Ttl;