#![forbid(unsafe_code)]
#![warn(missing_docs)]
mod aof;
mod aof_txn;
pub mod feed_meta;
pub mod layout;
mod replay;
mod replay_txn;
mod aof_policy;
mod aof_util;
mod crc32c;
mod record;
mod replay_resync;
pub mod reshard;
mod rewrite_fmt;
mod shards_meta;
mod snapshot_fmt;
mod snapshot_payload;
mod snapshot_read;
mod snapshot_write;
pub use aof::{AOF_MAGIC, Aof, Fsync, RewritePlan, RewriteStats};
pub use aof_util::write_aof_base;
pub use aof_policy::RewritePolicy;
pub use record::{AOF2_MAGIC, AofFormat, RecordStep, next_record, write_record_multibulk};
pub use replay::{ReplayReport, replay_aof, replay_aof_resync};
pub const REPLAY_DEMOTE_INTERVAL: u64 = 1024;
pub use shards_meta::{Routing, ShardsMeta, read_shards_meta, write_shards_meta};
pub use kevy_resp::{Argv, ArgvView};
pub use rewrite_fmt::{dump_aof, dump_store_to_buf, write_multibulk, write_stream_as_commands};
pub use snapshot_read::{
load_snapshot, load_snapshot_filtered, load_snapshot_from, read_snapshot_cursor,
};
pub use snapshot_write::{
save_snapshot, write_snapshot_tmp, write_snapshot_to, write_snapshot_to_with_cursor,
};
pub(crate) use rewrite_fmt::estimate_multibulk_bytes;
pub(crate) use snapshot_fmt::{SNAPSHOT_BUF_CAP, write_bytes};
pub(crate) use snapshot_write::write_stream_groups;
use kevy_store::Store;
use kevy_store::Value;
pub trait SnapshotSource {
fn for_each_entry(&self, f: impl FnMut(&[u8], &Value, Option<u64>));
fn for_each_hash_ttl(&self, _f: impl FnMut(&[u8], &[u8], u64)) {}
}
impl SnapshotSource for Store {
fn for_each_entry(&self, mut f: impl FnMut(&[u8], &Value, Option<u64>)) {
self.snapshot_each(|k, v, ttl| match self.materialize_cold(v) {
Some(hot) => f(k, &hot, ttl),
None => f(k, v, ttl),
});
}
fn for_each_hash_ttl(&self, f: impl FnMut(&[u8], &[u8], u64)) {
self.hash_ttl_each(f);
}
}
impl SnapshotSource for kevy_store::SnapshotView {
fn for_each_entry(&self, mut f: impl FnMut(&[u8], &Value, Option<u64>)) {
self.each(|k, v, ttl| match self.materialize_cold(v) {
Some(hot) => f(k, &hot, ttl),
None => f(k, v, ttl),
});
}
fn for_each_hash_ttl(&self, f: impl FnMut(&[u8], &[u8], u64)) {
self.each_hash_ttl(f);
}
}
#[cfg(test)]
mod tests;
#[cfg(test)]
mod tests_aof;
#[cfg(test)]
mod tests_rewrite;
#[cfg(test)]
mod tests_tier_stream;