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

Proposal: instead of returning null during missing ActorRef lookups, return Nobody instead #41

Closed
Aaronontheweb opened this issue Feb 21, 2014 · 5 comments

Comments

@Aaronontheweb
Copy link
Member

And pipe all messages directly to DeadLetters - Akka returns a reference to a static ActorRef.NoSender instance and this is the same idea. That way, rather than throw an exception, messages just get piped into the undeliverables pile.

Thoughts?

@rogeralsing
Copy link
Contributor

In what context? during ResolveActorRef ? ActorSelection?

@Aaronontheweb
Copy link
Member Author

I'm thinking

Context.Child and Context.ActorSelection

@rogeralsing
Copy link
Contributor

Yes, I checked the impl for getSingleChild on actorref, actorcell and actorselection, they all point to this method:

  override def getSingleChild(name: String): InternalActorRef =
    if (name.indexOf('#') == -1) {
      // optimization for the non-uid case
      getChildByName(name) match {
        case Some(crs: ChildRestartStats)  crs.child.asInstanceOf[InternalActorRef]
        case _                             Nobody

So you are correct :)
ActorCell.Child(...) in pigeon needs to be refactored to behave (and renamed) according to the scala code

@rogeralsing
Copy link
Contributor

I made ActorCell.Child(string name) use the extension to resolve Nobody, so we don't get null refs back from this.
In Akka, there are multiple methods for this, "Child(string name)" in their case, returns "some/none" FP style.. while getSingleChild returns Nobody if not found. ¨
Not sure if we need to make a distinction on this here?

@Aaronontheweb
Copy link
Member Author

@rogeralsing nah, seems like semantics. This is a good solution for the time being.

One thing we should consider adding (saw this in Akka) is an EmptyLocalAftorRef for this scenario - subclasses from LocalActorRef and just redirects all messages directly to DeadLetters. Seems like a good solution for being able to help debug scenarios where a Pigeon user is sending messages to a child that doesn't actually exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants