pub struct LoadBalancer {Show 16 fields
pub endpoints: Arc<RwLock<Vec<RpcEndpoint>>>,
pub rate_limiters: Arc<RwLock<HashMap<String, Arc<Mutex<DirectRateLimiter>>>>>,
pub client: Arc<RwLock<Client>>,
pub bind_addr: String,
pub health_check_interval_secs: Arc<RwLock<u64>>,
pub health_check_timeout_secs: Arc<RwLock<u64>>,
pub base_cooldown_secs: Arc<RwLock<u64>>,
pub max_cooldown_secs: Arc<RwLock<u64>>,
pub max_batch_size: Arc<RwLock<usize>>,
pub latency_smoothing_factor: Arc<RwLock<f64>>,
pub concurrency_limiter: Arc<Semaphore>,
pub config_path: Arc<RwLock<String>>,
pub connect_timeout_ms: Arc<RwLock<u64>>,
pub timeout_secs: Arc<RwLock<u64>>,
pub pool_idle_timeout_secs: Arc<RwLock<u64>>,
pub pool_max_idle_per_host: Arc<RwLock<usize>>,
}Fields§
§endpoints: Arc<RwLock<Vec<RpcEndpoint>>>§rate_limiters: Arc<RwLock<HashMap<String, Arc<Mutex<DirectRateLimiter>>>>>§client: Arc<RwLock<Client>>§bind_addr: String§health_check_interval_secs: Arc<RwLock<u64>>§health_check_timeout_secs: Arc<RwLock<u64>>§base_cooldown_secs: Arc<RwLock<u64>>§max_cooldown_secs: Arc<RwLock<u64>>§max_batch_size: Arc<RwLock<usize>>§latency_smoothing_factor: Arc<RwLock<f64>>§concurrency_limiter: Arc<Semaphore>§config_path: Arc<RwLock<String>>§connect_timeout_ms: Arc<RwLock<u64>>§timeout_secs: Arc<RwLock<u64>>§pool_idle_timeout_secs: Arc<RwLock<u64>>§pool_max_idle_per_host: Arc<RwLock<usize>>Implementations§
Source§impl LoadBalancer
impl LoadBalancer
pub fn new(config: Option<Config>, config_path: String) -> Self
pub fn reload_config(&self) -> Result<ReloadResponse, LoadBalancerError>
Sourcepub fn get_next_endpoint(&self, batch_size: usize) -> Option<RpcEndpoint>
pub fn get_next_endpoint(&self, batch_size: usize) -> Option<RpcEndpoint>
Selects the best available endpoint, updates its last_selected timestamp, and returns it.
Sourcepub async fn forward_raw_request(
&self,
request_body: Bytes,
endpoint: &RpcEndpoint,
method: &str,
) -> Result<Bytes, LoadBalancerError>
pub async fn forward_raw_request( &self, request_body: Bytes, endpoint: &RpcEndpoint, method: &str, ) -> Result<Bytes, LoadBalancerError>
A wrapper method that calls the main request forwarding logic.
pub async fn mark_rate_limited(&self, url: &str)
pub async fn mark_unhealthy(&self, url: &str)
pub async fn update_healthy_count(&self)
pub fn run_background_tasks( self: &Arc<Self>, shutdown_manager: &mut ShutdownManager, )
pub fn get_status(&self) -> Value
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LoadBalancer
impl !RefUnwindSafe for LoadBalancer
impl Send for LoadBalancer
impl Sync for LoadBalancer
impl Unpin for LoadBalancer
impl !UnwindSafe for LoadBalancer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more