Skip to main content

Replica

Struct Replica 

Source
pub struct Replica { /* private fields */ }
Expand description

An open replica.

Implementations§

Source§

impl Replica

Source

pub fn record_history( &self, batch_id: &str, pushed_at: u64, events: &[(&str, &[u8])], ) -> Result<(), CloudError>

Keep a batch the place answered (whatever each event’s status), in its order. An event already kept keeps its first batch.

Source

pub fn history_batches( &self, ) -> Result<Vec<Vec<Zeroizing<Vec<u8>>>>, CloudError>

Kept batches in push order, each event’s bytes in batch order.

Source

pub fn history_event( &self, event_id: &str, ) -> Result<Option<Zeroizing<Vec<u8>>>, CloudError>

The bytes of an own event kept in the history.

Source

pub fn key_lost_ids(&self) -> Result<Vec<String>, CloudError>

Event ids served without content after a failover (key_lost).

Source

pub fn stored_envelope( &self, event_id: &str, ) -> Result<Option<Value>, CloudError>

The signed envelope of a stored event (with its signature).

Source

pub fn unverified(&self) -> Result<Vec<(String, Value)>, CloudError>

Stored events that failed their checks (not purged, not key_lost), as envelope + body, to check again once the signer’s keys are current: a worker key fetched before its worker registered lists no worker, so that worker’s events failed on every member.

Source

pub fn mark_verified(&self, event_id: &str) -> Result<(), CloudError>

An unverified event passed its checks now: let it fold.

Source

pub fn restore_body( &self, event_id: &str, body: &Value, ) -> Result<(), CloudError>

A key_lost event’s content came back and verified: store it and let it fold.

Source

pub fn note_received(&self, seqs: &[u64], at: u64) -> Result<(), CloudError>

Note when the log delivered seqs.

Source

pub fn prune_history(&self, now_ms: u64) -> Result<usize, CloudError>

Drop batches and receive times older than KEEP_MS.

Source

pub fn rewind_seq(&self, now_ms: u64) -> Result<Option<u64>, CloudError>

The lowest seq received in the last 24 h.

Source

pub fn drop_changed_from( &self, from: u64, kept: &[(u64, String)], ) -> Result<usize, CloudError>

A re-tail from from returned kept (seq, event_id): every local row at or after from that did not come back with the same id is deleted, and the cursor goes back to from - 1 so the rows that came back are stored and folded again.

Source§

impl Replica

Source

pub fn insert_events( &mut self, events: &[StoredEvent], ) -> Result<usize, CloudError>

Store verified events; an event already stored (same seq) is left as it is. Returns how many were new.

Source

pub fn fold_events(&self) -> Result<Vec<FoldEvent>, CloudError>

Every stored event as the fold sees it, in seq order. A key_lost event moves the cursor like a failed signature and never folds until its content is repaired. A row marked converted moves it too and never folds again.

Source

pub fn first_saves(&self) -> Result<BTreeMap<String, Save>, CloudError>

The save history of every node: the seq of its first valid node.add and that event’s causal_base (the log position its writer had folded when it wrote it). A node whose first add names no causal_base is left out: its history is unknown (#286).

Source

pub fn shred_events(&mut self, ids: &BTreeSet<String>) -> Result<(), CloudError>

Shred the stored bodies of ids now, as Self::refold does for the events a folded purge names: for a tombstone applied before it is stored (a used-up transfer, driver::deletions).

Source

pub fn refold(&mut self) -> Result<Graph, CloudError>

Fold the whole stored log into the graph, store the materialised nodes and edges (fields encrypted) and move the cursor.

Source

pub fn node_fields(&self, node_id: &str) -> Result<Option<Value>, CloudError>

Fields of a materialised node, decrypted.

Source§

impl Replica

Source

pub fn open( data_dir: &Path, place_id: &str, mk: &[u8; 32], ) -> Result<(Self, Opened), CloudError>

Open (or create) the replica of place_id with the machine key mk.

Source

pub fn place_id(&self) -> &str

Source

pub fn dir(&self) -> &Path

Source

pub fn set_meta(&self, key: &str, value: &[u8]) -> Result<(), CloudError>

Source

pub fn meta(&self, key: &str) -> Result<Option<Zeroizing<Vec<u8>>>, CloudError>

Source

pub fn cursor(&self) -> Result<Option<u64>, CloudError>

Last server seq folded (None before the first clone).

Source

pub fn set_cursor(&self, seq: u64) -> Result<(), CloudError>

Move the cursor; it never goes back.

Source

pub fn epoch(&self) -> Result<Option<u64>, CloudError>

Source

pub fn set_epoch(&self, epoch: u64) -> Result<(), CloudError>

Source

pub fn id_salt(&self) -> Result<Option<[u8; 32]>, CloudError>

The place’s dedupe key pk_id once the server delivered id_salt.

Source

pub fn set_id_salt(&self, salt: &[u8; 32]) -> Result<(), CloudError>

Source

pub fn add_dedupe_key( &self, dk: &[u8; 32], node_id: &str, ) -> Result<(), CloudError>

Source

pub fn dedupe_node(&self, dk: &[u8; 32]) -> Result<Option<String>, CloudError>

The node an exact dedupe key belongs to.

Source

pub fn deny_purged(&self, dk: &[u8; 32], reason: &str) -> Result<(), CloudError>

Source

pub fn is_purged(&self, dk: &[u8; 32]) -> Result<bool, CloudError>

Whether a statement with this exact key was purged (capture step 3c).

Source

pub fn deny_node( &mut self, node_id: &str, reason: &str, ) -> Result<(), CloudError>

A purge removed node_id (SPEC-ENGINE §3.4.6 step 3): its dedupe keys move to purge_deny (same keyed digest, so the statement is never captured again) and its MinHash signature is deleted.

Source

pub fn purge_acks(&self) -> Result<PurgeAcks, CloudError>

Purge acknowledgements not yet accepted by the place: (purge_id, tombstone seq, applied_at ms), plus the ones already sent (an ack is made once per tombstone, its first applied_at kept).

Source

pub fn set_purge_acks(&self, acks: &PurgeAcks) -> Result<(), CloudError>

Source

pub fn put_signature( &self, node_id: &str, sig: &Signature, ) -> Result<(), CloudError>

Source

pub fn signatures(&self) -> Result<Vec<(String, Signature)>, CloudError>

Every stored signature, decrypted, in node-id order.

Source

pub fn add_pending( &self, event_id: &str, hlc_wall: u64, hlc_ctr: u16, outbox_id: Option<&str>, event: &[u8], ) -> Result<(), CloudError>

An own event waiting for the server log (offline or not yet tailed).

Source

pub fn pending(&self) -> Result<Vec<(String, Zeroizing<Vec<u8>>)>, CloudError>

Pending events in HLC order: (event_id, event bytes).

Source

pub fn settle_pending(&self, event_id: &str) -> Result<bool, CloudError>

The server log delivered event_id: it is no longer pending.

Source

pub fn put_own_source( &self, node_id: &str, source_kind: &str, source_ref: &Value, ) -> Result<(), CloudError>

Where an own-authored node’s text came from (capture step 6).

Source

pub fn own_source( &self, node_id: &str, ) -> Result<Option<(String, Value)>, CloudError>

Source

pub fn own_sources(&self) -> Result<Vec<(String, String, Value)>, CloudError>

Every own-authored node with its source, in node id order: what the capture lifecycle compares with the knowledge store.

Source

pub fn value_digest(&self, value: &str) -> String

hex(blake3_keyed(rk, value)), the value_digest of a source ref.

Trait Implementations§

Source§

impl Debug for Replica

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Replica

§

impl !RefUnwindSafe for Replica

§

impl !Sync for Replica

§

impl !UnwindSafe for Replica

§

impl Forget for Replica

§

impl Move for Replica

§

impl Send for Replica
where Connection: Send, RawVecInner: Send,

§

impl Unpin for Replica
where *mut sqlite3: Unpin, Arc<Mutex<*mut sqlite3>>: Unpin, *const u8 is !null: Unpin, *const Node<Arc<str>, RawStatement> is !null: Unpin,

§

impl UnsafeUnpin for Replica
where *mut sqlite3: UnsafeUnpin, *const ArcInner<Mutex<*mut sqlite3>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<*mut sqlite3>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<NonNull<Node<Arc<str>, RawStatement>>>: UnsafeUnpin, *const Node<Arc<str>, RawStatement> is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more