Class DependencyResolver
Provides users with immediate access to the IDependencyResolver bound to this ActorSystem, if any.
Implements
Inherited Members
Namespace: Akka.DependencyInjection
Assembly: Akka.DependencyInjection.dll
Syntax
public sealed class DependencyResolver : IExtension
Constructors
| Improve this Doc View SourceDependencyResolver(IDependencyResolver)
Declaration
public DependencyResolver(IDependencyResolver resolver)
Parameters
Type | Name | Description |
---|---|---|
IDependencyResolver | resolver |
Properties
| Improve this Doc View SourceResolver
The globally scoped IDependencyResolver.
Declaration
public IDependencyResolver Resolver { get; }
Property Value
Type | Description |
---|---|
IDependencyResolver |
Remarks
Per https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines - please use the appropriate Microsoft.Extensions.DependencyInjection.IServiceScope for your actors and the dependencies they consume. DI is typically not used for long-lived, stateful objects such as actors.
Therefore, injecting transient dependencies via constructors is a bad idea in most cases. You'd be far better off creating a local "request scope" each time your actor processes a message that depends on a transient dependency, such as a database connection, and disposing that scope once the operation is complete.
Actors are not MVC Controllers. Actors can live forever, have the ability to restart, and are often stateful. Be mindful of this as you use this feature or bad things will happen. Akka.NET does not magically manage scopes for you.
Methods
| Improve this Doc View SourceFor(ActorSystem)
Declaration
public static DependencyResolver For(ActorSystem actorSystem)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | actorSystem |
Returns
Type | Description |
---|---|
DependencyResolver |
Props(Type)
Used to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.
Declaration
public Props Props(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type of actor to instantiate. |
Returns
Type | Description |
---|---|
Props | A new Props instance which uses DI internally. |
Remarks
YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.
Props(Type, Object[])
Used to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.
Declaration
public Props Props(Type type, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type of actor to instantiate. |
Object[] | args | Optional. Any constructor arguments that will be passed into the actor's constructor directly without being resolved by DI first. |
Returns
Type | Description |
---|---|
Props | A new Props instance which uses DI internally. |
Remarks
YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.
Props<T>()
Used to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.
Declaration
public Props Props<T>()
where T : ActorBase
Returns
Type | Description |
---|---|
Props | A new Props instance which uses DI internally. |
Type Parameters
Name | Description |
---|---|
T | The type of actor to instantiate. |
Remarks
YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.
Props<T>(Object[])
Uses a delegate to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.
Declaration
public Props Props<T>(params object[] args)
where T : ActorBase
Parameters
Type | Name | Description |
---|---|---|
Object[] | args | Optional. Any constructor arguments that will be passed into the actor's constructor directly without being resolved by DI first. |
Returns
Type | Description |
---|---|
Props | A new Props instance which uses DI internally. |
Type Parameters
Name | Description |
---|---|
T | The type of actor to instantiate. |
Remarks
YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.