1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::actors::mailbox::Mailbox;
use crate::actors::envelope::Envelope;
use crate::actors::abstract_actor_ref::ActorRef;
pub struct DeadLetters {
is_planned: bool
}
impl DeadLetters {
pub fn new() -> DeadLetters {
DeadLetters {
is_planned: true
}
}
}
impl Mailbox for DeadLetters {
fn set_planned(self: &mut Self, _planned: bool) {
self.is_planned = true;
}
fn is_planned(self: &Self) -> bool {
true
}
fn enqueue(self: &mut Self, envelope: Envelope) {
let mut actor_name = "outside".to_string();
if envelope.sender.is_some() {
let sender = &mut envelope.sender.unwrap();
let sender_path = {
sender.path().name.clone()
};
if sender_path != "deadLetters" {
actor_name = sender.to_string();
}
}
println!("DeadLetter receive some message ... from '{}' to '{}'", actor_name, envelope.receiver)
}
fn dequeue(self: &mut Self) -> Envelope {
panic!("Try to dequeue deadLetter mailbox")
}
fn has_messages(self: &Self) -> bool {
false
}
fn clean_up(self: &mut Self, _sender: ActorRef, _dead_letters: ActorRef) {}
}