send

Macro send 

Source
macro_rules! send {
    ($($actor_name:literal, ($($msg:expr),*)),*) => { ... };
    ($($actor_name:literal, $($msg:expr),*),*) => { ... };
    ($($addr:expr, ($($msg:expr),*)),*) => { ... };
    ($($addr:expr, $($msg:expr),*),*) => { ... };
    (@DELEGATE; $($addr:expr, ($($msg:expr),*)),*) => { ... };
    (@SIZE; $($msg:expr),*) => { ... };
    (@SUB; $_msg:expr) => { ... };
    (@TO_ADDR; $actor_name:literal) => { ... };
}
Expand description

Sends one or more messages to one or more actors defined in the system. This function is responsible for gathering and dispatching messages received from the macro invocation of send!. Multiple messages can be grouped for one more actors in one send! macro invocation as shown below:

Example

use arrows::send;
use arrows::Msg;

let m1 = Msg::with_text("Message to actor1");
let m2 = Msg::with_text("Message to actor1");
let m3 = Msg::with_text("Message to actor2");
let m4 = Msg::with_text("Message to actor1");
let m5 = Msg::with_text("Message to actor1");
send!("actor1", (m1, m2), "actor2", (m3), "actor1", (m4, m5));

Grouping within braces is not necessary while sending only to one actor:

let m6 = Msg::with_text("Message to actor3")
let m7 = Msg::with_text("Message to actor3")
send!("actor3", m6, m7);

Actors identified with string literal such as ‘actor3’ is assumed to be running in the local system(they would be resurrected - if they are not - on message send).

Actors running in remote systems - need to be identified by the Addr construct:

use arrows::Addr;

let remote_addr1 = Addr::remote("actor1", "10.10.10.10:7171");
let remote_addr2 = Addr::remote("actor2", "11.11.11.11:8181");

let m1 = Msg::with_text("Message to remote actor1");
let m2 = Msg::with_text("Message to remote actor1");
let m3 = Msg::with_text("Message to remote actor2");
let m4 = Msg::with_text("Message to remote actor2");

send!(remote_addr1, (m1,m2), remote_addr2, (m3,m4));