atomr_core/actor/
deploy.rs1#[derive(Debug, Clone, Default, PartialEq, Eq)]
4pub struct Deploy {
5 pub path: Option<String>,
6 pub dispatcher: Option<String>,
7 pub mailbox: Option<String>,
8 pub scope: Scope,
9}
10
11#[derive(Debug, Clone, PartialEq, Eq, Default)]
12pub enum Scope {
13 #[default]
14 Local,
15 Remote {
16 address: String,
17 },
18}
19
20impl Deploy {
21 pub fn local() -> Self {
22 Self::default()
23 }
24
25 pub fn remote(address: impl Into<String>) -> Self {
26 Self { scope: Scope::Remote { address: address.into() }, ..Self::default() }
27 }
28
29 pub fn with_dispatcher(mut self, d: impl Into<String>) -> Self {
30 self.dispatcher = Some(d.into());
31 self
32 }
33
34 pub fn with_mailbox(mut self, m: impl Into<String>) -> Self {
35 self.mailbox = Some(m.into());
36 self
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn remote_deploy_sets_scope() {
46 let d = Deploy::remote("akka.tcp://S@host:1").with_dispatcher("dp");
47 assert!(matches!(d.scope, Scope::Remote { .. }));
48 assert_eq!(d.dispatcher.as_deref(), Some("dp"));
49 }
50}