Skip to content

Add per-actor-type runtime configuration overrides to Actors Next - #1879

Open
m3nax wants to merge 5 commits into
dapr:masterfrom
m3nax:feature/actors-next-per-type-options
Open

Add per-actor-type runtime configuration overrides to Actors Next#1879
m3nax wants to merge 5 commits into
dapr:masterfrom
m3nax:feature/actors-next-per-type-options

Conversation

@m3nax

@m3nax m3nax commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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 one SubscribeActorEvents stream 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:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

m3nax added 2 commits August 4, 2026 07:42
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
@m3nax
m3nax marked this pull request as ready for review August 4, 2026 07:54
@m3nax
m3nax requested review from a team as code owners August 4, 2026 07:54
@WhitWaldo
WhitWaldo requested a lite review from Copilot August 5, 2026 08:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 DaprActorTypeOptions and new registration APIs to capture per-type overrides alongside global DaprActorsOptions.
  • 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.

Comment thread src/Dapr.Actors.Next.Abstractions/Options/DaprActorsOptionsValidator.cs Outdated
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>
@WhitWaldo

Copy link
Copy Markdown
Contributor

@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 WhitWaldo 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.

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

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.

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)

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.

To resolve the CS0121, can you please mark this overload with [OverloadResolutionPriority]?

continue;
}

var actorName = registration.ActorImplementationType.Name;

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.

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; }

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.

Please consider adding the DrainRebalancedActorsTimeout to the per-actor options as well to pair with this property.

Comment thread all.sln Outdated
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
# Visual Studio Version 18
VisualStudioVersion = 18.8.12023.21

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.

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.

m3nax added 2 commits August 15, 2026 17:56
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
@m3nax

m3nax commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@WhitWaldo I've made the changes you asked for. Let me know if there's anything else.

@m3nax
m3nax requested a review from WhitWaldo August 15, 2026 16:02
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.

3 participants