use crate::rt::{BoxFuture, MaybeSend, MaybeSync};
use crate::store::{Key, Partition, Precondition, StoreError, Value, Write, codec::RelayV1};
pub(crate) const AUDIT_CAPACITY: &str = "automatic audit combined batch capacity";
pub trait RelayHook: MaybeSend + MaybeSync {
fn read_keys(
&self,
_target: &Partition,
_rows: &[(u64, RelayV1)],
) -> Result<Vec<Key>, StoreError> {
Ok(Vec::new())
}
fn before_apply_observed<'a>(
&'a self,
target: &'a Partition,
rows: &'a [(u64, RelayV1)],
_observed: &'a [(Key, Option<Value>)],
pre: &'a mut Vec<Precondition>,
writes: &'a mut Vec<Write>,
) -> BoxFuture<'a, Result<(), StoreError>> {
self.before_apply(target, rows, pre, writes)
}
fn reserved_ops(&self, _target: &Partition, _rows: &[(u64, RelayV1)]) -> usize {
0
}
fn before_apply<'a>(
&'a self,
target: &'a Partition,
rows: &'a [(u64, RelayV1)],
pre: &'a mut Vec<Precondition>,
writes: &'a mut Vec<Write>,
) -> BoxFuture<'a, Result<(), StoreError>>;
}
#[derive(Debug, Default, Clone, Copy)]
pub struct NoHook;
impl RelayHook for NoHook {
fn before_apply<'a>(
&'a self,
_target: &'a Partition,
_rows: &'a [(u64, RelayV1)],
_pre: &'a mut Vec<Precondition>,
_writes: &'a mut Vec<Write>,
) -> BoxFuture<'a, Result<(), StoreError>> {
Box::pin(async { Ok(()) })
}
}