ip hashing + test

This commit is contained in:
nnhphong
2025-12-10 02:28:09 -05:00
parent 8170d2a6bf
commit 90d326ba33
4 changed files with 307 additions and 3 deletions

View File

@@ -6,7 +6,19 @@ pub mod ip_hashing;
use std::fmt::Debug;
use std::sync::Arc;
use crate::backend::Backend;
use std::cell::RefCell;
use std::net::{SocketAddr};
thread_local! {
pub static CURRENT_CONNECTION_INFO: RefCell<Option<ConnectionInfo>> = RefCell::new(None);
}
#[derive(Clone, Debug)]
pub struct ConnectionInfo {
pub client_ip : SocketAddr,
}
pub trait Balancer: Debug + Send + Sync + 'static {
fn choose_backend(&mut self) -> Option<Arc<Backend>>;
}