< Summary

Information
Class: Elsa.Workflows.Runtime.WorkflowHeartbeatGeneratorFactory
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHeartbeatGeneratorFactory.cs
Line coverage
55%
Covered lines: 5
Uncovered lines: 4
Coverable lines: 9
Total lines: 26
Line coverage: 55.5%
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%11100%
CreateHeartbeatGenerator(...)100%11100%
UpdateTimestampAsync()100%210%

File(s)

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

#LineLine coverage
 1using Elsa.Common;
 2using Elsa.Workflows.Management;
 3using Elsa.Workflows.Runtime.Middleware.Workflows;
 4using Elsa.Workflows.Runtime.Options;
 5using Microsoft.Extensions.Logging;
 6using Microsoft.Extensions.Options;
 7
 8namespace Elsa.Workflows.Runtime;
 9
 43610public class WorkflowHeartbeatGeneratorFactory(IOptions<RuntimeOptions> options, ISystemClock systemClock, ILogger<Workf
 11{
 12    public HeartbeatGenerator CreateHeartbeatGenerator(WorkflowExecutionContext context)
 13    {
 47414        var inactivityThreshold = options.Value.InactivityThreshold;
 47415        var heartbeatInterval = TimeSpan.FromTicks((long)(inactivityThreshold.Ticks * 0.6));
 47416        logger.LogDebug("Workflow heartbeat interval: {Interval}", heartbeatInterval);
 47417        return new(async () => await UpdateTimestampAsync(context), heartbeatInterval, loggerFactory);
 18    }
 19
 20    private async Task UpdateTimestampAsync(WorkflowExecutionContext context)
 21    {
 022        var workflowInstanceStore = context.GetRequiredService<IWorkflowInstanceStore>();
 023        var workflowInstanceId = context.Id;
 024        await workflowInstanceStore.UpdateUpdatedTimestampAsync(workflowInstanceId, systemClock.UtcNow, context.Cancella
 025    }
 26}