-
Notifications
You must be signed in to change notification settings - Fork 352
Facility to provide interface while registering actors #1350
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
base: release-1.16
Are you sure you want to change the base?
Changes from 6 commits
5cc8189
87eedfd
404da07
c463186
c836bc4
41656aa
d06803e
49c9f3b
3985537
ec1ba43
20d9d4a
400b6eb
c72eab5
225130b
00c700b
8f34239
6f07643
3e32eb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,8 +136,11 @@ public void ConfigureServices(IServiceCollection services) | |
// Register actor runtime with DI | ||
services.AddActors(options => | ||
{ | ||
// Register actor types and configure actor settings | ||
// Register actor types and configure actor settings. | ||
options.Actors.RegisterActor<MyActor>(); | ||
|
||
// Register MyActor to a specific interface. | ||
options.Actors.RegisterActor<IMyActor, MyActor>(); | ||
|
||
// Configure default settings | ||
options.ActorIdleTimeout = TimeSpan.FromMinutes(10); | ||
|
@@ -150,6 +153,12 @@ public void ConfigureServices(IServiceCollection services) | |
services.AddSingleton<BankService>(); | ||
} | ||
``` | ||
> [!IMPORTANT] | ||
> When registering actors, note the return type requirements for the methods inside the interfaces: | ||
> * Pattern 1: `options.Actors.RegisterActor<MyActor>()` | ||
> * In this case, all interfaces implemented by `MyActor` must have methods that return only `Task` or `Task<T>`. This applies to every method in all interfaces `MyActor` implements. | ||
> * Pattern 2: `options.Actors.RegisterActor<IMyActor, MyActor>()` | ||
> * Here, only the `IMyActor` interface is required to have methods that return `Task` or `Task<T>`. Other interfaces `MyActor` are not subject to this restriction. | ||
Comment on lines
+156
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we force the use of I usually don't like to find out particularities from documentation, if possible I prefer my editor to guide me. What do you think about it? |
||
|
||
### Configuring JSON options | ||
|
||
|
@@ -241,4 +250,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
|
||
## Next steps | ||
|
||
Try the [Running and using virtual actors example]({{< ref dotnet-actors-howto.md >}}). | ||
Try the [Running and using virtual actors example]({{< ref dotnet-actors-howto.md >}}). |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.