pub struct ModulePool { /* private fields */ }Expand description
Module instance pool with load balancing.
Implementations§
Source§impl ModulePool
impl ModulePool
Sourcepub fn new(module_name: String, config: PoolConfig) -> Self
pub fn new(module_name: String, config: PoolConfig) -> Self
Creates a new module pool.
Sourcepub fn with_instance(module_name: String, instance: ModuleInstance) -> Self
pub fn with_instance(module_name: String, instance: ModuleInstance) -> Self
Creates a pool with a single instance.
Sourcepub fn add_instance(&self, instance: ModuleInstance) -> usize
pub fn add_instance(&self, instance: ModuleInstance) -> usize
Adds an instance to the pool.
Sourcepub fn remove_instance(&self, id: usize) -> Option<Arc<PooledInstance>>
pub fn remove_instance(&self, id: usize) -> Option<Arc<PooledInstance>>
Removes an instance from the pool.
Sourcepub fn select_instance(&self) -> Option<Arc<PooledInstance>>
pub fn select_instance(&self) -> Option<Arc<PooledInstance>>
Selects the best instance for a new request.
Sourcepub fn should_scale_up(&self) -> bool
pub fn should_scale_up(&self) -> bool
Checks if the pool should scale up.
Sourcepub fn should_scale_down(&self) -> bool
pub fn should_scale_down(&self) -> bool
Checks if the pool should scale down.
Sourcepub fn module_name(&self) -> &str
pub fn module_name(&self) -> &str
Returns the module name.
Sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
Returns the number of instances.
Sourcepub fn all_instances(&self) -> Vec<Arc<PooledInstance>>
pub fn all_instances(&self) -> Vec<Arc<PooledInstance>>
Returns all instances.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ModulePool
impl !RefUnwindSafe for ModulePool
impl Send for ModulePool
impl Sync for ModulePool
impl Unpin for ModulePool
impl UnsafeUnpin for ModulePool
impl UnwindSafe for ModulePool
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