< Summary

Information
Class: Elsa.Workflows.Management.Handlers.Notifications.EvictWorkflowDefinitionServiceCache
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Handlers/Notifications/EvictWorkflowDefinitionServiceCache.cs
Line coverage
36%
Covered lines: 4
Uncovered lines: 7
Coverable lines: 11
Total lines: 58
Line coverage: 36.3%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
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(...)100%11100%
HandleAsync(...)100%11100%
HandleAsync(...)100%210%
HandleAsync(...)100%11100%
HandleAsync()0%620%
HandleAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Handlers/Notifications/EvictWorkflowDefinitionServiceCache.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Management.Notifications;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Workflows.Management.Handlers.Notifications;
 6
 7/// <summary>
 8/// A workflow definition notifications handler for evicting the cache of the workflow definition service.
 9/// </summary>
 10/// <remarks>
 11/// This service listens for specific notifications and triggers cache invalidation operations accordingly.
 12/// </remarks>
 13[UsedImplicitly]
 31914internal class EvictWorkflowDefinitionServiceCache(IWorkflowDefinitionCacheManager workflowDefinitionCacheManager) :
 15    INotificationHandler<WorkflowDefinitionDraftSaving>,
 16    INotificationHandler<WorkflowDefinitionPublishing>,
 17    INotificationHandler<WorkflowDefinitionRetracting>,
 18    INotificationHandler<WorkflowDefinitionDeleting>,
 19    INotificationHandler<WorkflowDefinitionsDeleting>,
 20    INotificationHandler<WorkflowDefinitionVersionsUpdating>
 21{
 22    public Task HandleAsync(WorkflowDefinitionDraftSaving notification, CancellationToken cancellationToken)
 23    {
 224        return workflowDefinitionCacheManager.EvictWorkflowDefinitionAsync(notification.WorkflowDefinition.DefinitionId,
 25    }
 26
 27    /// <inheritdoc />
 28    public Task HandleAsync(WorkflowDefinitionPublishing notification, CancellationToken cancellationToken)
 29    {
 530        return workflowDefinitionCacheManager.EvictWorkflowDefinitionAsync(notification.WorkflowDefinition.DefinitionId,
 31    }
 32
 33    /// <inheritdoc />
 34    public Task HandleAsync(WorkflowDefinitionRetracting notification, CancellationToken cancellationToken)
 35    {
 036        return workflowDefinitionCacheManager.EvictWorkflowDefinitionAsync(notification.WorkflowDefinition.DefinitionId,
 37    }
 38
 39    /// <inheritdoc />
 40    public Task HandleAsync(WorkflowDefinitionDeleting notification, CancellationToken cancellationToken)
 41    {
 442        return workflowDefinitionCacheManager.EvictWorkflowDefinitionAsync(notification.DefinitionId, cancellationToken)
 43    }
 44
 45    /// <inheritdoc />
 46    public async Task HandleAsync(WorkflowDefinitionsDeleting notification, CancellationToken cancellationToken)
 47    {
 048        foreach (var definitionId in notification.DefinitionIds)
 049            await workflowDefinitionCacheManager.EvictWorkflowDefinitionAsync(definitionId, cancellationToken);
 050    }
 51
 52    /// <inheritdoc />
 53    public async Task HandleAsync(WorkflowDefinitionVersionsUpdating notification, CancellationToken cancellationToken)
 54    {
 055        foreach (var definition in notification.WorkflowDefinitions)
 056            await workflowDefinitionCacheManager.EvictWorkflowDefinitionAsync(definition.DefinitionId, cancellationToken
 057    }
 58}