< 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: 30
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>
 1214public class BackgroundStimulusDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IStimulusDispa
 15{
 16    /// <inheritdoc />
 17    public async Task<DispatchStimulusResponse> SendAsync(DispatchStimulusRequest request, CancellationToken cancellatio
 18    {
 719        var command = new DispatchStimulusCommand(request);
 20
 21        // Background commands run independently of caller's lifecycle.
 722        await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), CancellationToken.None);
 723        return DispatchStimulusResponse.Empty;
 724    }
 25
 26    private IDictionary<object, object> CreateHeaders()
 27    {
 728        return TenantHeaders.CreateHeaders(tenantAccessor.Tenant?.Id);
 29    }
 30}