pub struct Replica { /* private fields */ }Expand description
An open replica.
Implementations§
Source§impl Replica
impl Replica
Sourcepub fn record_history(
&self,
batch_id: &str,
pushed_at: u64,
events: &[(&str, &[u8])],
) -> Result<(), CloudError>
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.
Sourcepub fn history_batches(
&self,
) -> Result<Vec<Vec<Zeroizing<Vec<u8>>>>, CloudError>
pub fn history_batches( &self, ) -> Result<Vec<Vec<Zeroizing<Vec<u8>>>>, CloudError>
Kept batches in push order, each event’s bytes in batch order.
Sourcepub fn history_event(
&self,
event_id: &str,
) -> Result<Option<Zeroizing<Vec<u8>>>, CloudError>
pub fn history_event( &self, event_id: &str, ) -> Result<Option<Zeroizing<Vec<u8>>>, CloudError>
The bytes of an own event kept in the history.
Sourcepub fn key_lost_ids(&self) -> Result<Vec<String>, CloudError>
pub fn key_lost_ids(&self) -> Result<Vec<String>, CloudError>
Event ids served without content after a failover (key_lost).
Sourcepub fn stored_envelope(
&self,
event_id: &str,
) -> Result<Option<Value>, CloudError>
pub fn stored_envelope( &self, event_id: &str, ) -> Result<Option<Value>, CloudError>
The signed envelope of a stored event (with its signature).
Sourcepub fn unverified(&self) -> Result<Vec<(String, Value)>, CloudError>
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.
Sourcepub fn mark_verified(&self, event_id: &str) -> Result<(), CloudError>
pub fn mark_verified(&self, event_id: &str) -> Result<(), CloudError>
An unverified event passed its checks now: let it fold.
Sourcepub fn restore_body(
&self,
event_id: &str,
body: &Value,
) -> Result<(), CloudError>
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.
Sourcepub fn note_received(&self, seqs: &[u64], at: u64) -> Result<(), CloudError>
pub fn note_received(&self, seqs: &[u64], at: u64) -> Result<(), CloudError>
Note when the log delivered seqs.
Sourcepub fn prune_history(&self, now_ms: u64) -> Result<usize, CloudError>
pub fn prune_history(&self, now_ms: u64) -> Result<usize, CloudError>
Drop batches and receive times older than KEEP_MS.
Sourcepub fn rewind_seq(&self, now_ms: u64) -> Result<Option<u64>, CloudError>
pub fn rewind_seq(&self, now_ms: u64) -> Result<Option<u64>, CloudError>
The lowest seq received in the last 24 h.
Sourcepub fn drop_changed_from(
&self,
from: u64,
kept: &[(u64, String)],
) -> Result<usize, CloudError>
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
impl Replica
Sourcepub fn insert_events(
&mut self,
events: &[StoredEvent],
) -> Result<usize, CloudError>
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.
Sourcepub fn fold_events(&self) -> Result<Vec<FoldEvent>, CloudError>
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.
Sourcepub fn first_saves(&self) -> Result<BTreeMap<String, Save>, CloudError>
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).
Sourcepub fn shred_events(&mut self, ids: &BTreeSet<String>) -> Result<(), CloudError>
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).
Sourcepub fn refold(&mut self) -> Result<Graph, CloudError>
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.
Sourcepub fn node_fields(&self, node_id: &str) -> Result<Option<Value>, CloudError>
pub fn node_fields(&self, node_id: &str) -> Result<Option<Value>, CloudError>
Fields of a materialised node, decrypted.
Source§impl Replica
impl Replica
Sourcepub fn open(
data_dir: &Path,
place_id: &str,
mk: &[u8; 32],
) -> Result<(Self, Opened), CloudError>
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.
pub fn place_id(&self) -> &str
pub fn dir(&self) -> &Path
pub fn set_meta(&self, key: &str, value: &[u8]) -> Result<(), CloudError>
pub fn meta(&self, key: &str) -> Result<Option<Zeroizing<Vec<u8>>>, CloudError>
Sourcepub fn cursor(&self) -> Result<Option<u64>, CloudError>
pub fn cursor(&self) -> Result<Option<u64>, CloudError>
Last server seq folded (None before the first clone).
Sourcepub fn set_cursor(&self, seq: u64) -> Result<(), CloudError>
pub fn set_cursor(&self, seq: u64) -> Result<(), CloudError>
Move the cursor; it never goes back.
pub fn epoch(&self) -> Result<Option<u64>, CloudError>
pub fn set_epoch(&self, epoch: u64) -> Result<(), CloudError>
Sourcepub fn id_salt(&self) -> Result<Option<[u8; 32]>, CloudError>
pub fn id_salt(&self) -> Result<Option<[u8; 32]>, CloudError>
The place’s dedupe key pk_id once the server delivered id_salt.
pub fn set_id_salt(&self, salt: &[u8; 32]) -> Result<(), CloudError>
pub fn add_dedupe_key( &self, dk: &[u8; 32], node_id: &str, ) -> Result<(), CloudError>
Sourcepub fn dedupe_node(&self, dk: &[u8; 32]) -> Result<Option<String>, CloudError>
pub fn dedupe_node(&self, dk: &[u8; 32]) -> Result<Option<String>, CloudError>
The node an exact dedupe key belongs to.
pub fn deny_purged(&self, dk: &[u8; 32], reason: &str) -> Result<(), CloudError>
Sourcepub fn is_purged(&self, dk: &[u8; 32]) -> Result<bool, CloudError>
pub fn is_purged(&self, dk: &[u8; 32]) -> Result<bool, CloudError>
Whether a statement with this exact key was purged (capture step 3c).
Sourcepub fn deny_node(
&mut self,
node_id: &str,
reason: &str,
) -> Result<(), CloudError>
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.
Sourcepub fn purge_acks(&self) -> Result<PurgeAcks, CloudError>
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).
pub fn set_purge_acks(&self, acks: &PurgeAcks) -> Result<(), CloudError>
pub fn put_signature( &self, node_id: &str, sig: &Signature, ) -> Result<(), CloudError>
Sourcepub fn signatures(&self) -> Result<Vec<(String, Signature)>, CloudError>
pub fn signatures(&self) -> Result<Vec<(String, Signature)>, CloudError>
Every stored signature, decrypted, in node-id order.
Sourcepub fn add_pending(
&self,
event_id: &str,
hlc_wall: u64,
hlc_ctr: u16,
outbox_id: Option<&str>,
event: &[u8],
) -> Result<(), CloudError>
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).
Sourcepub fn pending(&self) -> Result<Vec<(String, Zeroizing<Vec<u8>>)>, CloudError>
pub fn pending(&self) -> Result<Vec<(String, Zeroizing<Vec<u8>>)>, CloudError>
Pending events in HLC order: (event_id, event bytes).
Sourcepub fn settle_pending(&self, event_id: &str) -> Result<bool, CloudError>
pub fn settle_pending(&self, event_id: &str) -> Result<bool, CloudError>
The server log delivered event_id: it is no longer pending.
Sourcepub fn put_own_source(
&self,
node_id: &str,
source_kind: &str,
source_ref: &Value,
) -> Result<(), CloudError>
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).
pub fn own_source( &self, node_id: &str, ) -> Result<Option<(String, Value)>, CloudError>
Sourcepub fn own_sources(&self) -> Result<Vec<(String, String, Value)>, CloudError>
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.
Sourcepub fn value_digest(&self, value: &str) -> String
pub fn value_digest(&self, value: &str) -> String
hex(blake3_keyed(rk, value)), the value_digest of a source ref.
Trait Implementations§
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
impl Unpin for Replica
impl UnsafeUnpin for Replicawhere
*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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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