-
Notifications
You must be signed in to change notification settings - Fork 10
Add a Receiver.new_receiver() method #382
Copy link
Copy link
Open
Labels
part:coreAffects the core types (`Sender`, `Receiver`, exceptions, etc.)Affects the core types (`Sender`, `Receiver`, exceptions, etc.)priority:highAddress this as soon as possibleAddress this as soon as possibletype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users
Milestone
Metadata
Metadata
Assignees
Labels
part:coreAffects the core types (`Sender`, `Receiver`, exceptions, etc.)Affects the core types (`Sender`, `Receiver`, exceptions, etc.)priority:highAddress this as soon as possibleAddress this as soon as possibletype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users
What's needed?
A way to, given a receiver, create a new receiver to receive from the same channel or source.
Proposed solution
Add a
Receiver.new_receiver()method that will basically create a new receiver in the same channel from the original receiver, with the same configuration of the receiver. It is basically a forward tochannel.new_receiver(), when a channel even exists. The default implementation will be to forward all messages received by the original receiver to the new receiver too (implemented usingPipeprobably).MapandFilterwould not use a pipe, but just callnew_receiveron their source receiver.Use cases
When working with actors, it is sometimes useful to split big tasks into smaller sub-actors. In this case, the parent actor needs to feed these sub-actors with receivers that comes from the receivers passed to the parent actor (for example when listening to dispatches, the subactors might need to listen to dispatches too).
In this case, the parent actor (which normally don't have access to the original channel) needs to create new channels to forward the messages to the sub-actors.