aboutsummaryrefslogtreecommitdiff
path: root/src/consul_actor.rs
diff options
context:
space:
mode:
authoradrien <adrien@luxeylab.net>2021-09-10 18:41:39 +0200
committeradrien <adrien@luxeylab.net>2021-09-10 18:41:39 +0200
commit4d76c3d78ade04038593aeef867294c9eee2a4b8 (patch)
tree8fac4937beafb831b7354bb2afa37bb5bea99e00 /src/consul_actor.rs
parent195aec2cfe738f4025ea540d2591f876e1d209b9 (diff)
downloaddiplonat-4d76c3d78ade04038593aeef867294c9eee2a4b8.tar.gz
diplonat-4d76c3d78ade04038593aeef867294c9eee2a4b8.zip
wrote the skeleton of ACME. Involved solving the cosmetic warnings about CamelCase for enums (without changing the API).
Diffstat (limited to 'src/consul_actor.rs')
-rw-r--r--src/consul_actor.rs29
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),