feat: complete jetstream deep operational parity closure

This commit is contained in:
Joseph Doherty
2026-02-23 13:43:14 -05:00
parent 5506fc4705
commit 377ad4a299
27 changed files with 933 additions and 13 deletions

View File

@@ -76,7 +76,7 @@ public sealed class PullConsumerEngine
}
if (consumer.Config.ReplayPolicy == ReplayPolicy.Original)
await Task.Delay(50, ct);
await Task.Delay(60, ct);
messages.Add(message);
if (consumer.Config.AckPolicy is AckPolicy.Explicit or AckPolicy.All)
@@ -101,11 +101,28 @@ public sealed class PullConsumerEngine
DeliverPolicy.New when state.LastSeq > 0 => state.LastSeq + 1,
DeliverPolicy.ByStartSequence when config.OptStartSeq > 0 => config.OptStartSeq,
DeliverPolicy.ByStartTime when config.OptStartTimeUtc is { } startTime => await ResolveByStartTimeAsync(stream, startTime, ct),
DeliverPolicy.LastPerSubject when state.LastSeq > 0 => state.LastSeq,
DeliverPolicy.LastPerSubject => await ResolveLastPerSubjectAsync(stream, config, state.LastSeq, ct),
_ => 1,
};
}
private static async ValueTask<ulong> ResolveLastPerSubjectAsync(
StreamHandle stream,
ConsumerConfig config,
ulong fallbackSequence,
CancellationToken ct)
{
var subject = config.ResolvePrimaryFilterSubject();
if (string.IsNullOrWhiteSpace(subject))
return fallbackSequence > 0 ? fallbackSequence : 1UL;
var last = await stream.Store.LoadLastBySubjectAsync(subject, ct);
if (last != null)
return last.Sequence;
return fallbackSequence > 0 ? fallbackSequence : 1UL;
}
private static async ValueTask<ulong> ResolveByStartTimeAsync(StreamHandle stream, DateTime startTimeUtc, CancellationToken ct)
{
var messages = await stream.Store.ListAsync(ct);