< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Workflows.Sequential.TimeoutExecutor
Assembly: NexusLabs.Needlr.AgentFramework.Workflows
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Sequential/TimeoutExecutor.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 32
Line coverage: 100%
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%
ExecuteAsync()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Sequential/TimeoutExecutor.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Workflows.Sequential;
 2
 3/// <summary>
 4/// Wraps an executor with a maximum execution duration. If the inner executor
 5/// does not complete within the specified timeout, the linked cancellation token
 6/// is triggered.
 7/// </summary>
 8/// <param name="inner">The executor to wrap.</param>
 9/// <param name="timeout">The maximum duration before cancellation.</param>
 10/// <example>
 11/// <code>
 12/// var executor = new TimeoutExecutor(innerExecutor, TimeSpan.FromSeconds(30));
 13///
 14/// // Throws OperationCanceledException if inner takes longer than 30 seconds.
 15/// var result = await executor.ExecuteAsync(context, cancellationToken);
 16/// </code>
 17/// </example>
 18[DoNotAutoRegister]
 619public sealed class TimeoutExecutor(
 620    IStageExecutor inner,
 621    TimeSpan timeout) : IStageExecutor
 22{
 23    /// <inheritdoc />
 24    public async Task<StageExecutionResult> ExecuteAsync(
 25        StageExecutionContext context,
 26        CancellationToken cancellationToken)
 27    {
 328        using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
 329        cts.CancelAfter(timeout);
 330        return await inner.ExecuteAsync(context, cts.Token);
 231    }
 32}