< Summary

Information
Class: Elsa.Workflows.Runtime.BookmarkQueueProcessor
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/BookmarkQueueProcessor.cs
Line coverage
91%
Covered lines: 21
Uncovered lines: 2
Coverable lines: 23
Total lines: 56
Line coverage: 91.3%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
ProcessAsync()75%4480%
ProcessPageAsync()100%22100%
ProcessItemAsync()100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/BookmarkQueueProcessor.cs

#LineLine coverage
 1using Elsa.Common.Entities;
 2using Elsa.Common.Models;
 3using Elsa.Extensions;
 4using Elsa.Workflows.Runtime.Entities;
 5using Elsa.Workflows.Runtime.OrderDefinitions;
 6using Microsoft.Extensions.Logging;
 7
 8namespace Elsa.Workflows.Runtime;
 9
 4810public class BookmarkQueueProcessor(IBookmarkQueueStore store, IWorkflowResumer workflowResumer, ILogger<BookmarkQueuePr
 11{
 12    public async Task ProcessAsync(CancellationToken cancellationToken = default)
 13    {
 4814        var batchSize = 50;
 4815        var offset = 0;
 16
 4817        while (!cancellationToken.IsCancellationRequested)
 18        {
 4419            var pageArgs = PageArgs.FromRange(offset, batchSize);
 4420            var page = await store.PageAsync(pageArgs, new BookmarkQueueItemOrder<DateTimeOffset>(x => x.CreatedAt, Orde
 21
 4422            await ProcessPageAsync(page, cancellationToken);
 23
 4424            if (page.Items.Count < batchSize)
 25                break;
 26
 027            offset += batchSize;
 028        }
 4829    }
 30
 31    private async Task ProcessPageAsync(Page<BookmarkQueueItem> page, CancellationToken cancellationToken = default)
 32    {
 228833        foreach (var bookmarkQueueItem in page.Items)
 110034            await ProcessItemAsync(bookmarkQueueItem, cancellationToken);
 4435    }
 36
 37    private async Task ProcessItemAsync(BookmarkQueueItem item, CancellationToken cancellationToken = default)
 38    {
 110039        var filter = item.CreateBookmarkFilter();
 110040        var options = item.Options;
 41
 110042        logger.LogDebug("Processing bookmark queue item {BookmarkQueueItemId} for workflow instance {WorkflowInstanceId}
 43
 110044        var responses = (await workflowResumer.ResumeAsync(filter, options, cancellationToken)).ToList();
 45
 110046        if (responses.Count > 0)
 47        {
 1848            logger.LogDebug("Successfully resumed {WorkflowCount} workflow instances using stimulus {StimulusHash} for a
 1849            await store.DeleteAsync(item.Id, cancellationToken);
 50        }
 51        else
 52        {
 108253            logger.LogDebug("No matching bookmarks found for bookmark queue item {BookmarkQueueItemId} for workflow inst
 54        }
 110055    }
 56}