< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.ProcessWorkflowDispatchOutbox
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/ProcessWorkflowDispatchOutbox.cs
Line coverage
85%
Covered lines: 12
Uncovered lines: 2
Coverable lines: 14
Total lines: 38
Line coverage: 85.7%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync()66.66%6676.92%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/ProcessWorkflowDispatchOutbox.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Runtime.Notifications;
 3using Elsa.Workflows.Runtime.Options;
 4using Microsoft.Extensions.DependencyInjection;
 5using Microsoft.Extensions.Logging;
 6using Microsoft.Extensions.Options;
 7
 8namespace Elsa.Workflows.Runtime.Handlers;
 9
 10/// <summary>
 11/// Processes the workflow dispatch outbox after a workflow state commit.
 12/// </summary>
 64513public class ProcessWorkflowDispatchOutbox(IServiceProvider serviceProvider, IOptions<WorkflowDispatcherOptions> options
 14{
 15    /// <inheritdoc />
 16    public async Task HandleAsync(WorkflowStateCommitted notification, CancellationToken cancellationToken)
 17    {
 53918        if (!options.Value.UseTransactionalOutbox || !options.Value.ProcessOutboxAfterCommit)
 53619            return;
 20
 321        if (!notification.WorkflowState.HasWorkflowDispatchOutboxItems())
 122            return;
 23
 24        try
 25        {
 226            var processor = serviceProvider.GetRequiredService<IWorkflowDispatchOutboxProcessor>();
 227            await processor.TryProcessAsync(cancellationToken);
 128        }
 029        catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
 30        {
 031            throw;
 32        }
 133        catch (Exception e) when (e is not OperationCanceledException)
 34        {
 135            logger.LogError(e, "Failed to process workflow dispatch outbox after workflow state commit; the recurring ou
 136        }
 53937    }
 38}