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

Add broadcast to ActorRegistry? #7

Closed
adamcik opened this issue Jun 24, 2011 · 3 comments
Closed

Add broadcast to ActorRegistry? #7

adamcik opened this issue Jun 24, 2011 · 3 comments
Assignees
Labels

Comments

@adamcik
Copy link

@adamcik adamcik commented Jun 24, 2011

Would something along the lines of ActorRegistry.broadcast(message, target=ActorClass) make sense? Would at least be a nice abstraction for idle in Mopidy if nothing else :)

    def broadcast(self, message, target=None):
        if target:
            refs = self.get_by_class(target)
        else:
            refs = self.get_all()

        for ref in refs:
            ref.send_one_way(message)

If this is out of the intended scope for pykka I could always just built a broadcast helper function somewhere in Mopidy :)

@jodal
Copy link
Owner

@jodal jodal commented Jun 25, 2011

Yes, I think so.

Though,

  • We should change target to klass, and allow other query forms, like urn to match all the get_by_* forms.
  • We should add block=False and timeout as kwargs, to allow for implementing e.g. stop_all using broadcast.
@adamcik
Copy link
Author

@adamcik adamcik commented Jun 25, 2011

To me broadcast implies just one way due to its semantics. A general send
all type thing can make sense, but not as a method called broadcast.

@jodal jodal closed this in e3e75ea Jun 25, 2011
@jodal
Copy link
Owner

@jodal jodal commented Jun 25, 2011

I agree: broadcast implies non-blocking and no response, thus block and timeout isn't in scope.

As urn identifies a single actor, it makes no sense for broadcast. I implemented it with a kwarg target_class which takes either a class or a class name. I chose target_class over target for consistency with the use of actor_class elsewhere in ActorRegistry and for allowing for other future ways to group actors without overloading a single target kwarg.

@ghost ghost assigned jodal Sep 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.