pub struct ReadRationing {
pub master_read_percent: u8,
/* private fields */
}Expand description
读写比例控制器:按比例把读请求路由到 master(强一致读)或 slave(弱一致读)
Fields§
§master_read_percent: u80..=100,表示有多少比例的读走 master 0 表示全部走 slave,100 表示全部走 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
默认 0% 走 master(全部走 slave)
Sourcepub fn default_master_only() -> Self
pub fn default_master_only() -> Self
默认 100% 走 master(强一致读)
Sourcepub fn should_read_master(&self) -> bool
pub fn should_read_master(&self) -> bool
决定本次读请求是否走 master
Sourcepub fn set_percent(&mut self, percent: u8)
pub fn set_percent(&mut self, percent: u8)
修改比例(运行时热更新)
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