Send a head start of the response immediately before dripping
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13a78f4268
commit
e48b6bb832
17 files changed
+120
-8
No files matched your search
@@ -19,14 +19,24 @@ public abstract class DripStrategy(
|
||||
public string Describe()
|
||||
{
|
||||
var current = options.CurrentValue;
|
||||
var head = current.HeadStartSize > 0 ? $" head {current.HeadStartSize}B" : "";
|
||||
return string.Create(
|
||||
CultureInfo.InvariantCulture,
|
||||
$"{Name} {current.MinDelay.TotalMilliseconds:0}-{current.MaxDelay.TotalMilliseconds:0}ms {current.MinChunkSize}-{current.MaxChunkSize}B");
|
||||
$"{Name} {current.MinDelay.TotalMilliseconds:0}-{current.MaxDelay.TotalMilliseconds:0}ms {current.MinChunkSize}-{current.MaxChunkSize}B{head}");
|
||||
}
|
||||
|
||||
public async Task RunAsync(ITrapChannel channel, CancellationToken ct)
|
||||
{
|
||||
foreach (var step in DripSchedule.Create(Content(random), random, options.CurrentValue))
|
||||
var current = options.CurrentValue;
|
||||
using var fragments = Content(random).GetEnumerator();
|
||||
|
||||
var head = DripSchedule.TakeHead(fragments, current.HeadStartSize);
|
||||
if (head.Length > 0)
|
||||
{
|
||||
await channel.WriteAsync(head, ct);
|
||||
}
|
||||
|
||||
foreach (var step in DripSchedule.Create(DripSchedule.Remaining(fragments), random, current))
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
await channel.WriteAsync(step.Chunk, ct);
|
||||
|
||||
Reference in new issue
Block a user