pub struct WriteKey {
pub key: String,
pub search_from: Option<u64>,
}Expand description
A caller-chosen name for one write, so that retrying it does not append the batch twice.
The key goes into the header of the WAL object. Nothing can tell from the key alone whether it was used before, so a retry says where to look:
WriteKey::newis a first attempt. The batch is written as it is, with no lookup, one put.WriteKey::retrymay be a retry. Before writing, the writer reads the headers of the WAL objects fromsearch_fromto the end, and if one carries the key it returns that object’s seq and writes nothing.search_fromhas to be at or before the original’s seq. The last seq the caller saw committed, plus one, is always safe.1is safe too and reads the whole log.
Either way, a put that runs into the writer’s own object at the seq it is trying (the store’s own retry after a lost acknowledgement does this) recognises it and returns that seq.
A key names one batch. Using it for a different batch is
ItzmaError::KeyConflict when the two bodies differ in length, and
silently drops the second batch when they do not, so derive keys from the
batch, for example <job>/<batch number>.
Fields§
§key: String1 to 128 bytes. Checked when the write is made, not here.
search_from: Option<u64>Where a retry starts looking for an earlier attempt. None skips the
lookup.
Implementations§
Trait Implementations§
impl Eq for WriteKey
impl StructuralPartialEq for WriteKey
Auto Trait Implementations§
impl Freeze for WriteKey
impl RefUnwindSafe for WriteKey
impl Send for WriteKey
impl Sync for WriteKey
impl Unpin for WriteKey
impl UnsafeUnpin for WriteKey
impl UnwindSafe for WriteKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more