< Summary

Information
Class: Elsa.Alterations.Services.BackgroundAlterationJobDispatcher
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Services/BackgroundAlterationJobDispatcher.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 25
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
DispatchAsync(...)100%210%
ExecuteJobAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Services/BackgroundAlterationJobDispatcher.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Mediator.Contracts;
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace Elsa.Alterations.Services;
 6
 7/// <summary>
 8/// Dispatches an alteration job for execution using an in-memory channel.
 9/// </summary>
 010public class BackgroundAlterationJobDispatcher(IJobQueue jobQueue, IServiceScopeFactory scopeFactory) : IAlterationJobDi
 11{
 12    /// <inheritdoc />
 13    public ValueTask DispatchAsync(string jobId, CancellationToken cancellationToken = default)
 14    {
 015        jobQueue.Enqueue(ct => ExecuteJobAsync(jobId, ct));
 016        return default;
 17    }
 18
 19    private async Task ExecuteJobAsync(string alterationJobId, CancellationToken cancellationToken)
 20    {
 021        using var scope = scopeFactory.CreateScope();
 022        var alterationJobRunner = scope.ServiceProvider.GetRequiredService<IAlterationJobRunner>();
 023        await alterationJobRunner.RunAsync(alterationJobId, cancellationToken);
 024    }
 25}