Skip to content

feat(streaming): add grain-backed stream checkpointer - #10345

Open
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:feat/grain-stream-checkpointer
Open

feat(streaming): add grain-backed stream checkpointer#10345
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:feat/grain-stream-checkpointer

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 6, 2026

Copy link
Copy Markdown
Member

Split from #8967.

Adds a provider-independent stream checkpointer backed by Orleans grain storage. Persistence interval, grain storage provider, and checkpoint ordering are configurable, with deterministic contract coverage for persistence, flushing, cancellation, failures, and monotonic updates.

Event Hubs can opt into the grain-backed checkpointer while Azure Table Storage remains the default. This unblocks the Kinesis provider in #8967.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3f5060d4-b229-476c-bdf3-9923ad459bb2

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a provider-independent, grain-storage-backed stream queue checkpointer to Orleans.Streaming, adds a reusable checkpoint comparer (numeric ordering for arbitrary-sized offsets), and wires the new checkpointer into Event Hubs as an opt-in alternative to the existing Azure Table checkpointer. It also adds deterministic contract tests to validate persistence, throttling, flushing, cancellation, failure propagation, and monotonic update behaviors.

Changes:

  • Add GrainStreamQueueCheckpointer (+ factory/options) and supporting grains/state for persisting checkpoints via Orleans grain storage.
  • Add StreamCheckpointComparers.Numeric and tests to ensure safe numeric ordering for Event Hubs-style offsets.
  • Add configuration extensions + docs/tests so Event Hubs providers can opt into the grain-based checkpointer while preserving existing defaults.
Show a summary per file
File Description
test/Orleans.Streaming.Tests/Checkpointers/StreamQueueCheckpointerTests.cs Adds deterministic contract tests for IStreamQueueCheckpointer<string> implementations.
test/Orleans.Streaming.Tests/Checkpointers/StreamCheckpointComparersTests.cs Adds unit tests for the new numeric checkpoint comparer behavior.
test/Orleans.Streaming.Tests/Checkpointers/GrainStreamQueueCheckpointerTests.cs Adds tests for grain-backed checkpointer behavior and grain/state integration.
test/Extensions/Orleans.Streaming.EventHubs.Tests/CheckpointerTests/EventHubCheckpointerTests.cs Updates EventHub checkpointer tests and adds ordering/no-advance coverage.
test/Extensions/Orleans.Streaming.EventHubs.Tests/CheckpointerTests/EventHubCheckpointerConfigurationTests.cs Adds DI/hosting tests for selecting grain vs Azure Table checkpointers.
src/Orleans.Streaming/QueueBalancer/PersistentStreamConfiguratorExtension.cs Adds UseGrainCheckpointer extension on ISiloPersistentStreamConfigurator.
src/Orleans.Streaming/Checkpointers/StreamCheckpointerGrainState.cs Introduces persisted grain state model for checkpoints.
src/Orleans.Streaming/Checkpointers/StreamCheckpointerGrain.cs Adds grain implementations to read/write checkpoints via grain storage.
src/Orleans.Streaming/Checkpointers/StreamCheckpointComparers.cs Introduces common checkpoint comparer(s), including numeric ordering.
src/Orleans.Streaming/Checkpointers/IStreamCheckpointerGrain.cs Introduces grain interface for checkpoint persistence (and configured variant).
src/Orleans.Streaming/Checkpointers/GrainStreamQueueCheckpointerOptions.cs Adds options for persistence interval, storage provider selection, and ordering.
src/Orleans.Streaming/Checkpointers/GrainStreamQueueCheckpointerFactory.cs Adds factory for creating grain-backed checkpointers per partition.
src/Orleans.Streaming/Checkpointers/GrainStreamQueueCheckpointer.cs Implements grain-backed checkpointing with throttling/flush semantics.
src/Azure/Orleans.Streaming.EventHubs/README.md Documents opting into grain storage for Event Hubs checkpoints.
src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamBuilder.cs Adds UseGrainCheckpointer for Event Hubs stream configurator (defaults numeric ordering).
src/api/Orleans.Streaming/Orleans.Streaming.cs Updates public API surface for new checkpointer/grain types/options/comparers/extensions.
src/api/Azure/Orleans.Streaming.EventHubs/Orleans.Streaming.EventHubs.cs Updates Event Hubs public API surface to include UseGrainCheckpointer.

Copilot's findings

  • Files reviewed: 17/17 changed files
  • Comments generated: 5

Comment on lines +198 to +200
await inProgressSave.WaitAsync(cancellationToken);

lock (_lock)
Comment on lines +12 to +15
[PreferLocalPlacement]
[GrainType("streamcheckpointergrain")]
public class StreamCheckpointerGrainGrain : Grain, IStreamCheckpointerGrain
{
Comment on lines +1 to +5
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using System;
using System.Threading.Tasks;
Comment on lines +162 to +164
context.GrainId.Returns(GrainId.Create(
"streamcheckpointergrain",
GrainStreamQueueCheckpointer.GetGrainKey(
Comment on lines +28 to +30
internal interface IConfiguredStreamCheckpointerGrain : IStreamCheckpointerGrain
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants