#![forbid(unsafe_code)]
#![warn(missing_docs)]
mod aof;
#[cfg(not(target_arch = "wasm32"))]
mod aof_mapped;
mod aof_policy;
mod aof_queue;
mod aof_rewrite;
#[cfg(not(target_arch = "wasm32"))]
mod aof_stage;
#[cfg(target_arch = "wasm32")]
mod aof_stage_off;
mod aof_sync;
mod aof_txn;
mod aof_util;
mod baseline;
mod crc32c;
mod dir_lock;
mod dump_cache;
pub mod feed_meta;
pub mod layout;
mod log_base;
mod modes;
mod record;
mod record_pieces;
mod replay;
mod replay_log;
mod replay_report;
mod replay_resync;
mod replay_txn;
mod replay_walk;
pub mod reshard;
mod reshard_journal;
mod rewrite_chunk;
mod rewrite_fmt;
mod rewrite_frames;
mod rewrite_stream_fmt;
mod segmented;
mod shards_meta;
mod snapshot_aux;
mod snapshot_commit;
mod snapshot_fmt;
mod snapshot_group_reads;
mod snapshot_payload;
mod snapshot_read;
mod snapshot_write;
#[cfg(not(target_arch = "wasm32"))]
mod stage_recover;
#[cfg(not(target_arch = "wasm32"))]
mod stage_ring;
pub use aof::{AOF_MAGIC, Aof};
pub use aof_policy::RewritePolicy;
pub use aof_rewrite::{RewritePlan, RewriteStats};
#[cfg(not(target_arch = "wasm32"))]
pub use aof_stage::StageOpen;
pub use aof_sync::PendingSync;
pub use baseline::estimate_rewrite_size;
pub use log_base::{is_log_base, settle_snapshot};
pub use modes::{Fsync, ReplayMode, ReplaySummary};
pub use record::{AOF2_MAGIC, AofFormat, RecordStep, next_record, write_record_multibulk};
pub use replay::{
ReplayReport, replay_aof, replay_aof_in_place, replay_aof_quiet, replay_aof_resync,
};
pub use segmented::{SEGMENTED, segmented_argv, segmented_frame};
pub const REPLAY_DEMOTE_INTERVAL: u64 = 1024;
pub use dir_lock::DirLock;
pub use kevy_resp::{Argv, ArgvView};
use kevy_store::Store;
use kevy_store::Value;
pub(crate) use rewrite_fmt::estimate_multibulk_bytes;
pub use rewrite_fmt::{dump_aof, dump_store_to_buf, write_multibulk};
pub use rewrite_frames::value_as_v1_frames;
pub use rewrite_stream_fmt::write_stream_as_commands;
pub use shards_meta::{Routing, ShardsMeta};
pub use snapshot_aux::WithAux;
pub(crate) use snapshot_fmt::{SNAPSHOT_BUF_CAP, write_bytes};
pub use snapshot_read::{
load_snapshot, load_snapshot_filtered, load_snapshot_from, load_snapshot_with_aux,
read_snapshot_cursor,
};
pub(crate) use snapshot_write::write_stream_groups;
pub use snapshot_write::{
save_snapshot, write_snapshot_tmp, write_snapshot_tmp_with_cursor, write_snapshot_to,
write_snapshot_to_with_cursor,
};
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)) {}
fn row_seg_files(&self) -> Vec<(u32, String)> {
Vec::new()
}
fn aux_frame(&self) -> Option<Argv> {
None
}
}
pub(crate) fn is_seg_stub(v: &Value) -> bool {
matches!(v, Value::Cold(c) if c.seg_parts().is_some())
}
impl SnapshotSource for Store {
fn for_each_entry(&self, mut f: impl FnMut(&[u8], &Value, Option<u64>)) {
self.snapshot_each(|k, v, ttl| {
if is_seg_stub(v) {
return f(k, v, ttl);
}
match self.materialize_cold(k, 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);
}
fn row_seg_files(&self) -> Vec<(u32, String)> {
self.row_seg_files()
}
}
impl SnapshotSource for kevy_store::SnapshotView {
fn for_each_entry(&self, mut f: impl FnMut(&[u8], &Value, Option<u64>)) {
self.each(|k, v, ttl| {
if is_seg_stub(v) {
return f(k, v, ttl);
}
match self.materialize_cold(k, v) {
Some(hot) => f(k, &hot, ttl),
None => f(k, v, ttl),
}
});
}
fn row_seg_files(&self) -> Vec<(u32, String)> {
kevy_store::SnapshotView::row_seg_files(self)
}
fn for_each_hash_ttl(&self, f: impl FnMut(&[u8], &[u8], u64)) {
self.each_hash_ttl(f);
}
}
const _: () = {
const fn send_sync<T: Send + Sync>() {}
send_sync::<Aof>();
send_sync::<Fsync>();
send_sync::<ReplayMode>();
send_sync::<ReplaySummary>();
send_sync::<RewritePlan>();
send_sync::<RewriteStats>();
send_sync::<RewritePolicy>();
#[cfg(not(target_arch = "wasm32"))]
send_sync::<StageOpen>();
send_sync::<PendingSync>();
send_sync::<ReplayReport>();
send_sync::<AofFormat>();
send_sync::<RecordStep<'static>>();
send_sync::<Routing>();
send_sync::<ShardsMeta>();
send_sync::<reshard::StdLayout>();
send_sync::<DirLock>();
};
#[cfg(test)]
mod tests;
#[cfg(test)]
mod tests_aof;
#[cfg(test)]
#[cfg(all(unix, not(target_arch = "wasm32")))]
mod tests_fail;
#[cfg(test)]
mod tests_log_base;
#[cfg(test)]
#[cfg(not(target_arch = "wasm32"))]
mod tests_log_base_fail;
#[cfg(test)]
#[cfg(not(target_arch = "wasm32"))]
mod tests_mapped;
#[cfg(test)]
mod tests_policy;
#[cfg(test)]
mod tests_rewrite;
#[cfg(test)]
#[cfg(not(target_arch = "wasm32"))]
mod tests_stage;
#[cfg(test)]
#[cfg(not(target_arch = "wasm32"))]
mod tests_stage_aof;
#[cfg(test)]
mod tests_sync;
#[cfg(test)]
mod tests_tier_stream;
#[cfg(test)]
mod tests_txn_tail;
#[cfg(test)]
#[cfg(unix)]
mod tests_zero_tail;