pub struct ShardPoolManager { /* private fields */ }Expand description
Shard pool manager
Implementations§
Source§impl ShardPoolManager
impl ShardPoolManager
Sourcepub fn new(strategy: ShardingStrategy) -> Self
pub fn new(strategy: ShardingStrategy) -> Self
Create a new shard pool manager
Sourcepub async fn remove_shard(&self, shard_id: u32) -> Result<()>
pub async fn remove_shard(&self, shard_id: u32) -> Result<()>
Remove a shard from the manager
Sourcepub fn get_shard_id(&self, key: &ShardKey) -> Result<u32>
pub fn get_shard_id(&self, key: &ShardKey) -> Result<u32>
Get shard ID for a given shard key
Sourcepub fn get_pool_by_id(&self, shard_id: u32) -> Result<PgPool>
pub fn get_pool_by_id(&self, shard_id: u32) -> Result<PgPool>
Get pool by shard ID
Sourcepub fn get_all_active_pools(&self) -> Vec<(u32, PgPool)>
pub fn get_all_active_pools(&self) -> Vec<(u32, PgPool)>
Get all active shard pools
Sourcepub fn get_shard_info(&self, shard_id: u32) -> Option<ShardInfo>
pub fn get_shard_info(&self, shard_id: u32) -> Option<ShardInfo>
Get shard info by ID
Sourcepub fn list_shards(&self) -> Vec<ShardInfo>
pub fn list_shards(&self) -> Vec<ShardInfo>
List all shards
Sourcepub fn set_shard_active(&self, shard_id: u32, active: bool) -> Result<()>
pub fn set_shard_active(&self, shard_id: u32, active: bool) -> Result<()>
Set shard active/inactive
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Get shard count
Sourcepub fn active_shard_count(&self) -> usize
pub fn active_shard_count(&self) -> usize
Get active shard count
Auto Trait Implementations§
impl Freeze for ShardPoolManager
impl !RefUnwindSafe for ShardPoolManager
impl Send for ShardPoolManager
impl Sync for ShardPoolManager
impl Unpin for ShardPoolManager
impl !UnwindSafe for ShardPoolManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more