Retry logic for SQL read replicas

This commit is contained in:
mdecimus
2024-08-13 17:17:38 +02:00
parent 6b92961c36
commit be656ddd0c
3 changed files with 174 additions and 21 deletions

View File

@@ -57,7 +57,7 @@ pub trait Serialize {
// Key serialization flags
pub(crate) const WITH_SUBSPACE: u32 = 1;
pub trait Key: Sync + Send {
pub trait Key: Sync + Send + Clone {
fn serialize(&self, flags: u32) -> Vec<u8>;
fn subspace(&self) -> u8;
}
@@ -154,6 +154,7 @@ pub const SUBSPACE_RESERVED_3: u8 = b'x';
pub const SUBSPACE_RESERVED_4: u8 = b'y';
pub const SUBSPACE_RESERVED_5: u8 = b'z';
#[derive(Clone)]
pub struct IterateParams<T: Key> {
begin: T,
end: T,
@@ -673,6 +674,16 @@ impl Store {
_ => false,
}
}
pub fn is_pg_or_mysql(&self) -> bool {
match self {
#[cfg(feature = "sqlite")]
Store::SQLite(_) => true,
#[cfg(feature = "postgres")]
Store::PostgreSQL(_) => true,
_ => false,
}
}
}
impl std::fmt::Debug for Store {