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

[WIP] New actor creation pipeline #2638

Closed
wants to merge 4 commits into from

Conversation

Horusiath
Copy link
Contributor

@Horusiath Horusiath commented Apr 30, 2017

DO NOT MERGE: work in progress

This PR brings some initial work on the ideas I've started to talk about in #1675 . Esentially it's simplification of an existing actor creation pipeline: instead of ActorProducer/ActorProducerPipeline/Resolver classes we can have single IDependencyResolver class directly under ActorSystem itself.

This also means that Akka.DI.Core is no longer needed. If user want ot setup it's own dependency resolver, he/she can set it up by calling actorSystem.UseDependencyResolver(dependencyResolverImpl) right after creating actor system.

This implementation also supports using dependency resolver for non-actor objects i.e. persistence EventAdapters. Ideally it would be great, if we could replace all Activator.CreateInstance calls with it.

Dependency resolver can be used for all actors not created via Props.Create(() => new MyActor(x, y, z)) as we know, that those actors are created totally correctly without it. It will be used for other types of props i.e.: you no longer need Props.DI().Create<MyActor>() as Props.Create<MyActor>() will rely on dependency resolver anyway.

There is also a support for partial DI application, so a situation when user may want to specify some of the arguments, while leaving the rest of them in a hands of a resolver. Example:

class MyActor : ActorBase
{
    public MyActor(IRepository injectedRepo, IActorRef manualRef) { }
}

Context.ActorOf(Props.Dynamic<MyActor>(new { manualRef }));

This will take anonymous object and by using reflection will try to match parameters provided as object properties by name and type (name and type must be an exact match at this point). Missing constructor parameters will be supplied from resolver.

Only regression at this point is that components created by resolver are not allowed to contain null values, as this is the way DR gets informed that it's expected to fill the missing parameter.

TODOs

  • fix akka.remote, akka.cluster and akka.persistence tests failures
  • apply dependency resolver for actor system extensions construction
  • apply dependency resolver for serializers construction
  • copy existing type registrations to new dependency resolver when UseDependencyResolver will be used to change it.

@Horusiath Horusiath added this to the 1.3.0 milestone May 28, 2017
@alexvaluyskiy alexvaluyskiy modified the milestones: 1.4.0, 1.3.0 Jun 27, 2017
@Horusiath
Copy link
Contributor Author

I'll send another PR for that.

@Horusiath Horusiath closed this Aug 30, 2017
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.

2 participants