diff options
Diffstat (limited to 'src/consul_actor.rs')
-rw-r--r-- | src/consul_actor.rs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/consul_actor.rs b/src/consul_actor.rs index dcbd79e..fd4d05f 100644 --- a/src/consul_actor.rs +++ b/src/consul_actor.rs @@ -14,9 +14,11 @@ use crate::consul; use crate::messages; #[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "snake_case")] pub enum DiplonatParameter { - tcp_port(HashSet<u16>), - udp_port(HashSet<u16>) + TcpPort(HashSet<u16>), + UdpPort(HashSet<u16>), + Acme(HashSet<String>) } #[derive(Serialize, Deserialize, Debug)] @@ -57,17 +59,19 @@ fn to_parameters(catalog: &consul::CatalogNode) -> Vec<DiplonatConsul> { } fn to_open_ports(params: &Vec<DiplonatConsul>) -> messages::PublicExposedPorts { - let mut op = messages::PublicExposedPorts { - tcp_ports: HashSet::new(), - udp_ports: HashSet::new() - }; + // let mut op = messages::PublicExposedPorts { + // tcp_ports: HashSet::new(), + // udp_ports: HashSet::new() + // }; + let mut op = messages::PublicExposedPorts::new(); for conf in params { let DiplonatConsul::diplonat(c) = conf; for parameter in c { match parameter { - DiplonatParameter::tcp_port(p) => op.tcp_ports.extend(p), - DiplonatParameter::udp_port(p) => op.udp_ports.extend(p), + DiplonatParameter::TcpPort(p) => op.tcp_ports.extend(p), + DiplonatParameter::UdpPort(p) => op.udp_ports.extend(p), + DiplonatParameter::Acme(urls) => op.acme.extend(urls.clone()), }; } } @@ -77,10 +81,11 @@ fn to_open_ports(params: &Vec<DiplonatConsul>) -> messages::PublicExposedPorts { impl ConsulActor { pub fn new(config: RuntimeConfigConsul) -> Self { - let (tx, rx) = watch::channel(messages::PublicExposedPorts{ - tcp_ports: HashSet::new(), - udp_ports: HashSet::new() - }); + let (tx, rx) = watch::channel(messages::PublicExposedPorts::new()); + // let (tx, rx) = watch::channel(messages::PublicExposedPorts{ + // tcp_ports: HashSet::new(), + // udp_ports: HashSet::new() + // }); return Self { consul: consul::Consul::new(&config.url), |