mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 06:48:37 +08:00
Something is ok (cleanup)
This commit is contained in:
@@ -6,28 +6,6 @@ use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
/*
|
||||
pub fn run1() {
|
||||
let mut upstreams = LoadBalancer::try_from_iter(vec!["192.168.1.10:8000", "192.168.1.1:8000", "127.0.0.1:8000"]).unwrap();
|
||||
env_logger::init();
|
||||
let hc = TcpHealthCheck::new();
|
||||
upstreams.set_health_check(hc);
|
||||
upstreams.health_check_frequency = Some(Duration::from_secs(1));
|
||||
|
||||
let background = background_service("health check", upstreams);
|
||||
let upstreams = background.task();
|
||||
let mut server = Server::new(None).unwrap();
|
||||
server.bootstrap();
|
||||
|
||||
let mut proxy = pingora_proxy::http_proxy_service(&server.configuration, proxyhttp::LB(upstreams));
|
||||
|
||||
proxy.add_tcp("0.0.0.0:6193");
|
||||
server.add_service(background);
|
||||
server.add_service(proxy);
|
||||
server.run_forever();
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn run() {
|
||||
env_logger::init();
|
||||
|
||||
@@ -35,13 +13,18 @@ pub fn run() {
|
||||
server.bootstrap();
|
||||
|
||||
let upstreams_map: DashMap<String, (Vec<(String, u16)>, AtomicUsize)> = DashMap::new();
|
||||
let config = Arc::new(RwLock::new(upstreams_map)); // Wrap in Arc<RwLock<...>>
|
||||
let config = Arc::new(RwLock::new(upstreams_map));
|
||||
|
||||
let lb = LB { upstreams_map: config.clone() }; // Share the Arc<RwLock<...>>
|
||||
let bg_service = BGService { upstreams_map: config.clone() }; // Share the Arc<RwLock<...>>
|
||||
let lb = LB {
|
||||
upstreams: config.clone(),
|
||||
// umap_full: config.clone(),
|
||||
};
|
||||
let bg_service = BGService {
|
||||
upstreams: config.clone(),
|
||||
// umap_full: config.clone(),
|
||||
};
|
||||
|
||||
let bg_srvc = background_service("bgsrvc", bg_service);
|
||||
bg_srvc.task();
|
||||
|
||||
let mut proxy = pingora_proxy::http_proxy_service(&server.configuration, lb);
|
||||
proxy.add_tcp("0.0.0.0:6193");
|
||||
|
||||
Reference in New Issue
Block a user