-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make ActorRef an interface or The breaking-just-about-everything PR #762
Conversation
BREAKING CHANGES: ActorRef == and != has been removed. This means all actorRef1 == actorRef2 must be replaced with Equals(actorRef1, actorRef2) Tell(object message), ie the implicit sender overload, has been moved to an extension method, and requires a "using Akka.Actor;" ActorRef.NoSender -> ActorRefs.NoSender ActorRef.Nobody -> ActorRefs.Nobody Implicit cast from ActorRef to Routee has been replaced with Routee.FromActorRef(actorRef) You might need to add a using Akka.Actor; to be able to use Tell with implicit sender.
From now on, an ActorRef implementation need to implement both ActorRef and InternalActorRef interfaces. Before this was the ActorRef hiearchy. Every ActorRef (except NoSender) had to inherit from InternaActorRef Akka.Actor.ActorRef + Akka.Actor.InternalActorRef | + Akka.Actor.ActorRefWithCell | | + Akka.Actor.LocalActorRef | | | + Akka.Actor.RootGuardianActorRef | | | + Akka.TestKit.TestActorRef<T> | | + Akka.Actor.RepointableActorRef ... (other classes removed) + Akka.Actor.NoSender Now ActorRef and InternalActorRef are interfaces and we have two new base classes: ActorRefBase : ActorRef and InternalActorRefBase : ActorRefBase, InternalActorRef and the hierarchy is: Akka.Actor.ActorRef + Akka.Actor.ActorRefBase | + Akka.Actor.InternalActorRefBase | | + Akka.Actor.ActorRefWithCell | | | + Akka.Actor.LocalActorRef | | | | + Akka.Actor.RootGuardianActorRef ... (other classes removed) However there is no need for ActorRefs to inherit from the base classes. Implementing InternalActorRef is a requirement though.
cc @Aaronontheweb we need to decide what PR of this and yours we merge first, what cause the least friction? |
@HCanber what's the reasoning behind putting |
@rogeralsing @HCanber doesn't matter to me which one goes first, but we should do all of the smaller PRs first before we do either of these big ones. Thinking of @jcwrequests's DI one in particular (needs to be rebased on dev.) Either I way, I volunteer myself to clean up the mess when we try to merge both of these in :p |
Actually, we should probably do mine first - I don't think mine has any breaking API changes. @HCanber's can be done safely on top of mine I think. |
@HCanber @rogeralsing @Aaronontheweb if there is anything that I can do with my pull request to help I am certainly open. I am just not sure if I rebase my PR if there will be any problems. In my day job I am usually the only dev committing so I don't run into issues requiring squashing. |
@jcwrequests here's what you should do:
That way there are no merge conflicts with dev and it's easy to review. Does that make sense? |
It's only the So the alternatives would have been: And, since it can be implemented as a extension method, and it really is a "convenience" method, I thought that was the best alternative. @jcwrequests You can find more information on how to handle these kind of issues here: Contributing.md |
@HCanber thanks for the explanation - that makes perfect sense. |
@HCanber thanks for the info. |
Fixes #480 Make ActorRef an interface
Related to #633 Fix interface naming conventions
and #652 Prefix user-facing interfaces with "I" to match .NET Convention
The current implementation
The hierarchy for an actor ref looks like this:
Every actor ref, except
Akka.Actor.NoSender
, has to inherit fromInternalActorRef
as the core framework casts actor refs toInternalActorRef
to get access to internal members.The new implementation
This PR introduces two new interfaces:
IActorRef
andIInternalActorRef
. Every concrete class has to implement these two interfaces, but does not otherwise have to inherit from any base classes.What's been done
The existing abstract class
ActorRef
has been renamed toActorRefBase
and the new interfaceIActorRef
is used everywhere instead ofActorRef
.The same thing has been done to
InternalActorRef
: It has been renamed toInternalActorRefBase
and the new interfaceIInternalActorRef
is used.Since
IActorRef
is an interface the operators==
!=
has been removed.ActorRef.Nobody
andActorRef.NoSender
has been moved toActorRefs
.Tell(object message)
is now an extension method.The commits and reviewing
This PR consists of three commits (oldest to newest):
ActorRef
toActorRefBase
and introduces an interfaceActorRef
and other things that had to change due toActorRef
being an interface.InternalActorRef
toInternalActorRefBase
and introduces a interfaceInternalActorRef
ActorRef
toIActorRef
andInternalActorRef
toIInternalActorRef
This should make it a bit easier to review as renaming from ActorRef to IActorRef modifies 206 files and has been lifted out to its own commit.
The first two commits contains the real code changes and needs reviewing.
Breaking changes to the public API
ActorRef
-->IActorRef
ActorRef.Nobody
-->ActorRefs.Nobody
ActorRef.NoSender
-->ActorRefs.NoSender
ActorRef
's operators==
and!=
has been removed. This means all expressions likeactorRef1 == actorRef2
must be replaced withEquals(actorRef1, actorRef2)
Tell(object message)
, i.e. the implicit sender overload, has been movedto an extension method, and requires
using Akka.Actor;
to be accessible.ActorRef
toRoutee
has been replaced withRoutee.FromActorRef(actorRef)