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
//! The placement hook of a clustered node.
//!
//! A single node hosts every virtual actor whose chart type it knows. In a cluster, each
//! virtual actor lives on the node that leases its shard, so the node asks a [`Placement`]
//! where an actor lives before it delivers a message to it or activates it. Without a
//! placement (the default), the node behaves exactly as a single node.
//!
//! The answer is a [`Route`]:
//!
//! - [`Route::Local`]: this node hosts the actor now; deliver and activate as usual.
//! - [`Route::Remote`]: another node hosts it; the message goes into the given mailbox, which
//! carries it there. Messages already waiting in the local mailbox are moved there too, and
//! an activation on this node is deactivated first.
//! - [`Route::Hold`]: no node may host it now (its shard is unowned or its owner is gone); the
//! message waits in the local mailbox and the actor is not activated.
//!
//! [`Placement::route`] sees every message to a virtual actor or a stateless worker before it
//! is delivered, so a cluster can also balance worker requests and observe their replies.
//!
//! @tg: implements:: [[decisions#Placement is a runtime hook with three answers]]
use Arc;
use crateAddress;
use crate;
/// Where an actor lives now.
/// Decides where virtual actors and stateless workers live in a cluster.