Make the hold method configurable in the dashboard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9a56fc5b48
commit
6b9bf3cd5f
40 files changed
+815
-134
No files matched your search
@@ -17,7 +17,7 @@ public sealed partial class TrapRunner(
|
||||
{
|
||||
public async Task<TrapOutcome> RunAsync(
|
||||
TrapContext context,
|
||||
Func<CancellationToken, ValueTask<ITrapChannel>> openChannel,
|
||||
Func<ITarpitStrategy, CancellationToken, ValueTask<ITrapChannel>> openChannel,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var session = context.Session;
|
||||
@@ -30,6 +30,7 @@ public sealed partial class TrapRunner(
|
||||
}
|
||||
|
||||
using var _ = lease;
|
||||
var description = strategy is IStrategyDetails details ? details.Describe() : strategy.Name;
|
||||
using var hold = new CancellationTokenSource(options.CurrentValue.MaxHoldDuration, timeProvider);
|
||||
using var linked = CancellationTokenSource.CreateLinkedTokenSource(ct, hold.Token);
|
||||
|
||||
@@ -37,7 +38,7 @@ public sealed partial class TrapRunner(
|
||||
var outcome = TrapOutcome.Completed;
|
||||
try
|
||||
{
|
||||
channel = new CountingTrapChannel(await openChannel(linked.Token));
|
||||
channel = new CountingTrapChannel(await openChannel(strategy, linked.Token));
|
||||
await strategy.RunAsync(channel, linked.Token);
|
||||
}
|
||||
catch (OperationCanceledException) when (linked.IsCancellationRequested)
|
||||
@@ -51,7 +52,7 @@ public sealed partial class TrapRunner(
|
||||
outcome = TrapOutcome.ClientAborted;
|
||||
}
|
||||
|
||||
Publish(context, strategy.Name, channel?.BytesSent ?? 0, outcome);
|
||||
Publish(context, description, channel?.BytesSent ?? 0, outcome);
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user