pub struct ReadRationing {
pub master_read_percent: u8,
/* private fields */
}Expand description
Read-write ratio controller: routes read requests to master (strong consistency read) or slave (weak consistency read) by ratio
Fields§
§master_read_percent: u80..=100, indicates what ratio of reads go to master 0 means all reads go to slave, 100 means all reads go to master
Implementations§
Source§impl ReadRationing
impl ReadRationing
pub fn new(master_read_percent: u8) -> Self
Sourcepub fn default_slave_only() -> Self
pub fn default_slave_only() -> Self
Default 0% to master (all reads go to slave)
Sourcepub fn default_master_only() -> Self
pub fn default_master_only() -> Self
Default 100% to master (strong consistency read)
Sourcepub fn should_read_master(&self) -> bool
pub fn should_read_master(&self) -> bool
Decide whether this read request should go to master
Sourcepub fn set_percent(&mut self, percent: u8)
pub fn set_percent(&mut self, percent: u8)
Update the ratio (runtime hot update)
Trait Implementations§
Source§impl Clone for ReadRationing
impl Clone for ReadRationing
Source§impl Debug for ReadRationing
impl Debug for ReadRationing
Source§impl Default for ReadRationing
impl Default for ReadRationing
Source§impl<'de> Deserialize<'de> for ReadRationing
impl<'de> Deserialize<'de> for ReadRationing
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for ReadRationing
impl RefUnwindSafe for ReadRationing
impl Send for ReadRationing
impl Sync for ReadRationing
impl Unpin for ReadRationing
impl UnsafeUnpin for ReadRationing
impl UnwindSafe for ReadRationing
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