Repository navigation
feat(runtime): add shared grain activation setup - #11305
Merged
ReubenBond merged 1 commit intoSep 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The runtime lifecycle changes are broad and warrant final human review.
Review effort: Lite
Findings: None
What changed in this PR
Adds grain-scoped activation setup composition before lifecycle startup.
Changes:
- Adds cached, ordered activation setup actions.
- Integrates setup across activation paths and lifecycle handling.
- Adds tests, API metadata, and documentation examples.
| File | Summary |
|---|---|
test/Orleans.Runtime.Internal.Tests/ActivationsLifeCycleTests/ActivationDataLifecycleTests.cs |
Adds coverage for ordering, failures, scopes, and stateless workers. |
src/Orleans.Runtime/Catalog/GrainTypeSharedContext.cs |
Adds setup registration and configuration sealing. |
src/Orleans.Runtime/Catalog/ActivationData.cs |
Runs setup during activation construction. |
src/Orleans.Runtime/Activation/IGrainContextActivator.cs |
Completes shared-context configuration. |
src/api/Orleans.Runtime/Orleans.Runtime.cs |
Updates the generated API surface. |
docs/site/src/content/docs/snippets/compiled/Grains/GrainSnippets.cs |
Adds a compiled setup example. |
docs/site/src/content/docs/implementation/orleans-lifecycle.md |
Documents activation composition; use “registration order” terminology. |
docs/site/src/content/docs/grains/grain-lifecycle.md |
Adds shared activation setup guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Code coverage
Report-only conclusion: regressed. The current-main baseline is commit 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 |
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Grain-scoped features need a composition point after the grain is fully constructed and before lifecycle startup. Providers currently own individual enrollment paths, and a reusable integration can otherwise require a feature-specific grain base class or an extra scoped registrar for every activation.
Solution
Add
GrainTypeSharedContext.AddActivationSetup(Action<IGrainContext>). ExistingIConfigureGrainTypeComponentsimplementations select applicable grain classes once while configuring a shared context, then compose reusable setup actions. Each activation invokes that cached plan afterGrainInstanceis assigned and creation accounting completes, before the grain object's lifecycle participation and lifecycle startup. Setup registration closes when shared configuration completes.The actions run in registration order and can explicitly resolve activation-scoped state or enroll existing
ILifecycleParticipant<IGrainLifecycle>implementations. Shared actions can execute concurrently across activations; actual feature state stays in the activation scope. Custom grain activators and individual stateless workers use the same boundary. Setup failures follow normal activation failure and disposal handling.Compatibility and rationale
Existing concrete, keyed, participant-interface, and manually enrolled DI registrations retain their current behavior. Applicability and shared setup are explicit; the runtime adds no service sweep, per-activation registrar, participant array, or identity set. Activations without setup take a null-delegate fast path. Existing grain-object participation, migration, and lifecycle stage ordering are preserved.
Includes focused activation coverage, generated API surface, and a compiled documentation example selecting grain classes by an application-owned interface. This is the runtime prerequisite for the separate composition-based Journaling work and replacement of #11279; Journaling source changes remain in that follow-up.
Microsoft Reviewers: Open in CodeFlow