use serde::Serialize;
use crate::config::host::Host;
pub mod build;
pub mod file_source;
pub mod merge;
pub mod paths;
pub mod reconciler;
pub mod service;
pub mod store_source;
pub mod validate;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub enum RouteSourceKind {
File,
Docker,
#[allow(dead_code)]
Kubernetes,
Store,
}
#[derive(Debug, Clone)]
pub struct RouteSnapshot {
pub source: RouteSourceKind,
pub hosts: Vec<Host>,
pub revision: Option<u64>,
}
impl RouteSnapshot {
pub fn new(source: RouteSourceKind, hosts: Vec<Host>) -> Self {
Self {
source,
hosts,
revision: None,
}
}
}
pub type SnapshotSender = tokio::sync::mpsc::Sender<RouteSnapshot>;
#[cfg(test)]
pub(crate) mod test_utils {
use crate::config::Route;
pub fn host(name: &str, upstream_ip: &str) -> crate::config::host::Host {
crate::config::host::Host::from_route(&route(name, upstream_ip))
}
pub fn route(host: &str, upstream_ip: &str) -> Route {
serde_json::from_value(serde_json::json!({
"host": host,
"upstreams": [{ "ip": upstream_ip, "port": 3000 }],
}))
.unwrap()
}
}