Struct apalis_core::worker::Recipient
source · pub struct Recipient<M: Message>(_);Available on crate feature
worker only.Expand description
Address of actor. Can be used to send messages to it.
Implementations§
source§impl<M> Recipient<M>where
M: Message + Send,
M::Result: Send,
impl<M> Recipient<M>where
M: Message + Send,
M::Result: Send,
sourcepub async fn send(&self, m: M) -> Option<M::Result>
pub async fn send(&self, m: M) -> Option<M::Result>
Send message to actor
Examples found in repository?
More examples
src/worker/broker.rs (line 46)
37 38 39 40 41 42 43 44 45 46 47 48 49
pub async fn issue_send<M: BrokerMessage + Send + Sync>(&self, m: M) {
let entry = if let Entry::Occupied(entry) = self.message_entry(TypeId::of::<M>()) {
entry
} else {
return;
};
let send = entry.get().iter().filter_map(|(_, recipient)| {
recipient
.downcast_ref::<Recipient<M>>()
.map(|recipient| recipient.send(m.clone()))
});
drop(future::join_all(send).await);
}