feat(journaling): support composition on plain grains - #11279
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Prevent stale work-item coalescing after recovery-generation changes and correct the related reset wording.
Review effort: Lite
Findings: None
What changed in this PR
Adds grain-scoped Journaling participants, initializing durable state before recovery.
Changes:
- Adds the participant contract and
DurableGrainintegration. - Updates recovery-generation fencing and state rebinding.
- Adds lifecycle, recovery, failure, and factory tests.
- Updates the generated API surface.
| File | Summary |
|---|---|
test/Orleans.Journaling.Tests/StateManagerTests.cs |
Tests recovery fencing scenarios. |
test/Orleans.Journaling.Tests/JournaledGrainParticipantTests.cs |
Tests participant lifecycle and activation behavior. |
src/Orleans.Journaling/JournaledStateManager.cs |
Adds recovery-generation fencing and state rebinding. |
src/Orleans.Journaling/IJournaledGrainParticipant.cs |
Defines the participant contract. |
src/Orleans.Journaling/DurableGrain.cs |
Resolves and initializes participants during construction. |
src/api/Orleans.Journaling/Orleans.Journaling.cs |
Updates the generated public API. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: current-main baseline stale. The newest successful coverage run tested 9222be9, not current main d515d75. Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
a135812 to
65c73bd
Compare
65c73bd to
7ecb8bb
Compare
7ecb8bb to
5c33af8
Compare
5c33af8 to
3497499
Compare
3497499 to
15be673
Compare
Enables journaled state composition on ordinary grains and application-defined grain base classes. The standard state manager enrolls itself in the activation lifecycle in its grain-bound constructor, so injected durable state recovers during
SetupStatebeforeOnActivateAsyncand requests.AddJournalStoragesupplies the scoped manager through a construction-only factory. Resolving journal state or a manager creates the activation's manager; configured features can materialize their state through shared activation setup.This supersedes this PR's original
IJournaledGrainParticipant.Initialize()proposal with the runtime'sIConfigureGrainTypeComponentsandGrainTypeSharedContext.AddActivationSetupcomposition boundary. A configurator selects grain classes once per type and registers a shared action which resolves activation-scoped feature services after grain construction and assignment, before lifecycle startup. Scoped features can enroll their existing lifecycle participants for asynchronous startup and shutdown.DurableGrainremains an optional convenience forStateManager,GetOrCreateState, andWriteStateAsync. Grain code relies on lifecycle enrollment being complete when its scoped manager resolves. The standard manager establishes that guarantee in its grain-bound constructor; custom managers establish it in their constructor or registration factory. An enrollment failure disposes the partially constructed manager and propagates the original error. Explicit-JournalIdand storage-only construction retain caller-owned initialization/disposal and independent journal identity.The change includes focused composition, isolation, recovery, failure, constructor-enrollment, and provider-coherence coverage, along with updated Journaling guidance and source-backed compiled examples. README, documentation, and runnable Azure sample operations accept cancellation tokens and flow them through grain calls, journal writes, and provider I/O. Runnable clients use the host stopping token for operations and the configured shutdown deadline for graceful cleanup. The generated Journaling API matches the runtime foundation's surface after removing the unmerged participant addition; the released compatibility baseline is preserved.
Runtime prerequisite #11305 merged into
dotnet/orleans:mainat9303d4ec7cd76ba7f9f41f61fc13774e86430003. This PR is rebased onto that upstream commit, so its diff contains only the Journaling composition changes. Review the immutable Journaling-only comparison.Downstream consumers in #11280 and #10693 adapt separately: move feature materialization from the specialized participant bootstrap into shared activation setup, resolve state through
context.ActivationServices, and enroll feature lifecycle work before startup. Their branches remain separately owned.Microsoft Reviewers: Open in CodeFlow