mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 14:58:38 +08:00
51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
use crate::utils::consul;
|
|
use crate::utils::filewatch;
|
|
use crate::utils::structs::Configuration;
|
|
use crate::web::webserver;
|
|
use async_trait::async_trait;
|
|
use futures::channel::mpsc::Sender;
|
|
|
|
pub struct FromFileProvider {
|
|
pub path: String,
|
|
}
|
|
pub struct APIUpstreamProvider {
|
|
pub config_api_enabled: bool,
|
|
pub address: String,
|
|
pub masterkey: String,
|
|
pub tls_address: Option<String>,
|
|
pub tls_certificate: Option<String>,
|
|
pub tls_key_file: Option<String>,
|
|
pub file_server_address: Option<String>,
|
|
pub file_server_folder: Option<String>,
|
|
}
|
|
|
|
pub struct ConsulProvider {
|
|
pub path: String,
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait Discovery {
|
|
async fn start(&self, tx: Sender<Configuration>);
|
|
}
|
|
|
|
#[async_trait]
|
|
impl Discovery for APIUpstreamProvider {
|
|
async fn start(&self, toreturn: Sender<Configuration>) {
|
|
webserver::run_server(self, toreturn).await;
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl Discovery for FromFileProvider {
|
|
async fn start(&self, tx: Sender<Configuration>) {
|
|
tokio::spawn(filewatch::start(self.path.clone(), tx.clone()));
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl Discovery for ConsulProvider {
|
|
async fn start(&self, tx: Sender<Configuration>) {
|
|
tokio::spawn(consul::start(self.path.clone(), tx.clone()));
|
|
}
|
|
}
|