Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added source generator for actor type registration #1401

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

WhitWaldo
Copy link
Contributor

Description

Using the .NET SDK today, one must register each actor type with dependency injection like so:

services.AddActors(options => {
  options.Actors.RegisterActor<MyActorA>();
  options.Actors.RegisterActor<MyActorB>();
  options.Actors.RegisterActor<MyActorC>();
  options.Actors.RegisterActor<MyActorD>();
});

As one uses an increasing number of actor types, this can get cumbersome to deal with maintaining this list of types. That's where this source generator comes into play. If all the actors are in the same project, the developer need only do the following:

services.RegisterAllActors();

And if the developer is interested in also including actor types from any assemblies referenced by the project as well, they need only indicate as much, as follows:

services.RegisterAllActors(true);

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: N/A

This was the result of a conversation between @philliphoff and myself recently.

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

…type that implements Dapr.Actors.Runtime.Actor

Signed-off-by: Whit Waldo <[email protected]>
…s from transient project references

Signed-off-by: Whit Waldo <[email protected]>
@WhitWaldo WhitWaldo self-assigned this Nov 5, 2024
@WhitWaldo WhitWaldo requested review from a team as code owners November 5, 2024 20:05
@WhitWaldo WhitWaldo added this to the Future milestone Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant