< Summary

Information
Class: Elsa.Common.Multitenancy.TenantBackgroundWorkQueueWorker
Assembly: Elsa.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Multitenancy/Implementations/TenantBackgroundWorkQueueWorker.cs
Line coverage
66%
Covered lines: 12
Uncovered lines: 6
Coverable lines: 18
Total lines: 37
Line coverage: 66.6%
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%
ExecuteAsync()50%2257.14%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Multitenancy/Implementations/TenantBackgroundWorkQueueWorker.cs

#LineLine coverage
 1using Elsa.Common.Helpers;
 2using Microsoft.Extensions.Logging;
 3
 4namespace Elsa.Common.Multitenancy;
 5
 136public class TenantBackgroundWorkQueueWorker(
 137    ITenantBackgroundWorkQueue workQueue,
 138    IServiceProvider serviceProvider,
 139    ILogger<TenantBackgroundWorkQueueWorker> logger) : BackgroundTask
 10{
 11    public override async Task ExecuteAsync(CancellationToken cancellationToken)
 12    {
 13        try
 14        {
 1315            await using var enumerator = workQueue.DequeueAllAsync(cancellationToken).GetAsyncEnumerator(cancellationTok
 2616            while (await enumerator.MoveNextAsync())
 17            {
 18                try
 19                {
 1320                    await enumerator.Current(serviceProvider, cancellationToken);
 1321                }
 022                catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
 23                {
 024                    return;
 25                }
 026                catch (Exception e) when (!e.IsFatal())
 27                {
 028                    logger.LogError(e, "A tenant background work item failed.");
 029                }
 30            }
 031        }
 1232        catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
 33        {
 1234            logger.LogDebug("Tenant background work queue worker stopped because cancellation was requested.");
 1235        }
 1236    }
 37}