Add per-actor-type runtime configuration overrides to Actors Next - #1879
Add per-actor-type runtime configuration overrides to Actors Next#1879m3nax wants to merge 5 commits into
Conversation
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class support for per-actor-type runtime configuration overrides (“type options”) in Actors Next, and wires those overrides through registration, source generation, and sidecar stream advertisement so each actor type can publish a merged SubscribeActorEventsInitialConfig.
Changes:
- Introduces
DaprActorTypeOptionsand new registration APIs to capture per-type overrides alongside globalDaprActorsOptions. - Updates stream advertisement to merge per-type overrides over the effective (global/per-registration) options when building
SubscribeActorEventsInitialConfig. - Expands unit/integration coverage and adds a new tutorial example demonstrating per-type idle timeout and reentrancy overrides.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/Dapr.IntegrationTest.Actors.Next/RealSidecarActorTests.cs | Adds integration coverage verifying per-type merged config is advertised to the real sidecar. |
| test/Dapr.Actors.Next.SourceGenerators.Test/GeneratorTests.cs | Verifies generator emits typeOptions: and that explicit type options flow into runtime registration. |
| test/Dapr.Actors.Next.Core.Test/GeneratedActorEventsTransportTests.cs | Adds coverage for initial-config mapping (drain/reentrancy/depth) into entity config. |
| test/Dapr.Actors.Next.Core.Test/CoreRuntimeTests.cs | Adds coverage for global defaults, per-type merged overrides, and override precedence in stream advertisement. |
| test/Dapr.Actors.Next.Core.Test/CoreEdgeCaseTests.cs | Asserts runtime registration + builder surface TypeOptions consistently. |
| test/Dapr.Actors.Next.Analyzers.Test/ActorsNextAnalyzerTests.cs | Adds analyzer scenario using explicit registration alias with type options. |
| test/Dapr.Actors.Next.Abstractions.Test/OptionsTests.cs | Adds options-level tests for storing/overwriting/validating/preserving type options. |
| src/Dapr.Actors.Next.SourceGenerators/ActorsNextSourceGenerator.cs | Updates generated module to pass per-type options into registration builder calls. |
| src/Dapr.Actors.Next.Core/Transport/SubscribeActorEventsStreamManager.cs | Merges per-type overrides when creating SubscribeActorEventsInitialConfig. |
| src/Dapr.Actors.Next.Core/Registration/ActorRuntimeRegistrationBuilder.cs | Extends builder Add overloads to accept per-type options. |
| src/Dapr.Actors.Next.Core/Registration/ActorRuntimeRegistration.cs | Stores TypeOptions on runtime registration for downstream advertisement. |
| src/Dapr.Actors.Next.Abstractions/Options/DaprActorTypeOptions.cs | New options type defining nullable per-type override fields. |
| src/Dapr.Actors.Next.Abstractions/Options/DaprActorsOptionsValidator.cs | Extends validation to include per-type option validation. |
| src/Dapr.Actors.Next.Abstractions/Options/DaprActorRegistrationCollection.cs | Adds RegisterActor overloads that accept per-type override configuration. |
| src/Dapr.Actors.Next.Abstractions/Options/DaprActorRegistration.cs | Extends explicit registration metadata to carry TypeOptions. |
| examples/Actor.Next/README.md | Adds new example entry for per-type options. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.Tests/Store.Next.Example07.Tests.csproj | New test project for the per-type options example. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.Tests/PerTypeOptionsTests.cs | Example tests verifying runtime registrations receive per-type overrides. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.http | Adds request script for the sample endpoints. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.csproj | New sample project showcasing per-type options. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.AppHost/Store.Next.Example07.AppHost.csproj | Adds Aspire AppHost for running sample + sidecar together. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.AppHost/Properties/launchSettings.json | Launch settings for the AppHost. |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.AppHost/Directory.Build.props | AppHost build props (target framework/packability). |
| examples/Actor.Next/07-PerTypeOptions/Store.Next.Example07.AppHost/AppHost.cs | Configures the sample project with a Dapr sidecar via Aspire. |
| examples/Actor.Next/07-PerTypeOptions/README.md | Documents the per-type options sample and how to run it. |
| examples/Actor.Next/07-PerTypeOptions/Properties/launchSettings.json | Launch settings for the sample app. |
| examples/Actor.Next/07-PerTypeOptions/Program.cs | Sample app wiring: global defaults + per-type overrides + minimal API endpoints. |
| examples/Actor.Next/07-PerTypeOptions/InventoryActor.cs | Inventory actor type used by the per-type options sample. |
| examples/Actor.Next/07-PerTypeOptions/CheckoutSessionActor.cs | Checkout session actor type used by the per-type options sample. |
| examples/Actor.Next/07-PerTypeOptions/appsettings.json | Kestrel endpoint config for HTTP API + gRPC app channel. |
| all.sln | Adds the new example projects to the solution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Manuel Menegazzo <65919883+m3nax@users.noreply.github.com>
|
@m3nax This tentatively looks great - excellent idea. I'll give it a more thorough review this week and get it merged in. Thank you for taking the time! |
WhitWaldo
left a comment
There was a problem hiding this comment.
Thank you for your contribution. This is an excellent addition and I thank you for taking the time to put it together. I've made a couple of notes throughout - could you please review each of them and correct accordingly so I can get this merged and released? Again, thank you!
| /// over the actor event stream, so they have no effect when | ||
| /// <see cref="DaprActorsOptions.EnableSidecarTransport"/> is <see langword="false"/>. | ||
| /// </summary> | ||
| public sealed class DaprActorTypeOptions |
There was a problem hiding this comment.
Please consider adding DisableStateMigration on a per-actor option as it's in the DaprActorsOptions today. The other properties are fine to leave as a global value, but this would allow a per-type opt-out.
| /// <summary> | ||
| /// Registers an actor type for hosting. | ||
| /// </summary> | ||
| public void RegisterActor<TActor>(string? actorTypeName = null) |
There was a problem hiding this comment.
To resolve the CS0121, can you please mark this overload with [OverloadResolutionPriority]?
| continue; | ||
| } | ||
|
|
||
| var actorName = registration.ActorImplementationType.Name; |
There was a problem hiding this comment.
I might suggest this be changed to registration.ActorTypeName ?? registration.ActorImplementationType.Name so the message will match what's advertised (e.g. if a custom ActorTypeName is specified).
| /// Gets or sets a value indicating whether rebalanced actors of this type drain in-flight calls. | ||
| /// <see langword="null"/> inherits <see cref="DaprActorsOptions.DrainRebalancedActors"/>. | ||
| /// </summary> | ||
| public bool? DrainRebalancedActors { get; set; } |
There was a problem hiding this comment.
Please consider adding the DrainRebalancedActorsTimeout to the per-actor options as well to pair with this property.
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.3.32929.385 | ||
| # Visual Studio Version 18 | ||
| VisualStudioVersion = 18.8.12023.21 |
There was a problem hiding this comment.
Please revert lines 3-4 as I only modify these to track the .NET releases so we don't accidentally introduce errors for users on older VS versions.
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
|
@WhitWaldo I've made the changes you asked for. Let me know if there's anything else. |
Description
This PR adds per-actor-type runtime configuration overrides to Actors Next. Today the idle timeout, drain, and reentrancy settings can only be configured globally through
DaprActorsOptions, even though the runtime already opens oneSubscribeActorEventsstream per actor type and the protocol (ActorEntityConfig) supports per-entity overrides.Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: