feat(cli): historyread --held-marker-file for hand-paged reads

This commit is contained in:
Joseph Doherty
2026-11-24 00:42:46 -05:00
parent 3b630ab1a9
commit b50019db9c
3 changed files with 12 additions and 1 deletions
@@ -99,6 +99,10 @@ public class HistoryReadCommand : CommandBase
[CommandOption("resume-when-file", Description = "With --pause-after-page: resume once this file exists (it is not read or deleted)")]
public string? ResumeWhenFile { get; init; }
/// <summary>Written (empty) once the hand-paged read reaches its pause / abandon / release point, so a driver knows the page is held.</summary>
[CommandOption("held-marker-file", Description = "With --page-size: create this file when the read reaches its pause, abandon or release point")]
public string? HeldMarkerFile { get; init; }
/// <summary>How long a pause waits for <c>--resume-when-file</c> before giving up.</summary>
[CommandOption("pause-timeout", Description = "With --pause-after-page: seconds to wait for --resume-when-file (default 300)")]
public int PauseTimeoutSeconds { get; init; } = 300;
@@ -203,6 +207,7 @@ public class HistoryReadCommand : CommandBase
if (number == AbandonAfterPage)
{
await console.Output.WriteLineAsync($"Abandoned after page {number} (continuation not released; holding {HoldSeconds}s)");
if (HeldMarkerFile is not null) await File.WriteAllTextAsync(HeldMarkerFile, "", ct);
if (HoldSeconds > 0) await Task.Delay(TimeSpan.FromSeconds(HoldSeconds), ct);
return;
}
@@ -210,12 +215,14 @@ public class HistoryReadCommand : CommandBase
{
var released = await service.HistoryReadPageAsync(details, nodeId, cp, true, ct);
await console.Output.WriteLineAsync($"Released after page {number}: {Format(released.Status)}");
if (HeldMarkerFile is not null) await File.WriteAllTextAsync(HeldMarkerFile, "", ct);
if (HoldSeconds > 0) await Task.Delay(TimeSpan.FromSeconds(HoldSeconds), ct);
return;
}
if (number == PauseAfterPage)
{
await console.Output.WriteLineAsync($"Paused after page {number}; waiting for {ResumeWhenFile}");
if (HeldMarkerFile is not null) await File.WriteAllTextAsync(HeldMarkerFile, "", ct);
var deadline = DateTime.UtcNow.AddSeconds(PauseTimeoutSeconds);
while (!File.Exists(ResumeWhenFile))
{