< Summary

Information
Class: Elsa.Workflows.Runtime.BackgroundStimulusDispatcher
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/BackgroundStimulusDispatcher.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 28
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
SendAsync()100%11100%
CreateHeaders()50%22100%

File(s)

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

#LineLine coverage
 1using Elsa.Common.Multitenancy;
 2using Elsa.Mediator;
 3using Elsa.Mediator.Contracts;
 4using Elsa.Tenants.Mediator;
 5using Elsa.Workflows.Runtime.Commands;
 6using Elsa.Workflows.Runtime.Requests;
 7using Elsa.Workflows.Runtime.Responses;
 8
 9namespace Elsa.Workflows.Runtime;
 10
 11/// <summary>
 12/// A simple implementation that queues the specified request for delivering stimuli on a non-durable background worker.
 13/// </summary>
 614public class BackgroundStimulusDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IStimulusDispa
 15{
 16    /// <inheritdoc />
 17    public async Task<DispatchStimulusResponse> SendAsync(DispatchStimulusRequest request, CancellationToken cancellatio
 18    {
 319        var command = new DispatchStimulusCommand(request);
 320        await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), cancellationToken);
 321        return DispatchStimulusResponse.Empty;
 322    }
 23
 24    private IDictionary<object, object> CreateHeaders()
 25    {
 326        return TenantHeaders.CreateHeaders(tenantAccessor.Tenant?.Id);
 27    }
 28}