Trait OpStore

Source
pub trait OpStore:
    'static
    + Send
    + Sync
    + Debug {
    // Required methods
    fn process_incoming_ops(
        &self,
        op_list: Vec<Bytes>,
    ) -> BoxFuture<'_, K2Result<Vec<OpId>>>;
    fn retrieve_op_hashes_in_time_slice(
        &self,
        arc: DhtArc,
        start: Timestamp,
        end: Timestamp,
    ) -> BoxFuture<'_, K2Result<(Vec<OpId>, u32)>>;
    fn retrieve_ops(
        &self,
        op_ids: Vec<OpId>,
    ) -> BoxFuture<'_, K2Result<Vec<MetaOp>>>;
    fn filter_out_existing_ops(
        &self,
        op_ids: Vec<OpId>,
    ) -> BoxFuture<'_, K2Result<Vec<OpId>>>;
    fn retrieve_op_ids_bounded(
        &self,
        arc: DhtArc,
        start: Timestamp,
        limit_bytes: u32,
    ) -> BoxFuture<'_, K2Result<(Vec<OpId>, u32, Timestamp)>>;
    fn earliest_timestamp_in_arc(
        &self,
        arc: DhtArc,
    ) -> BoxFuture<'_, K2Result<Option<Timestamp>>>;
    fn store_slice_hash(
        &self,
        arc: DhtArc,
        slice_index: u64,
        slice_hash: Bytes,
    ) -> BoxFuture<'_, K2Result<()>>;
    fn slice_hash_count(&self, arc: DhtArc) -> BoxFuture<'_, K2Result<u64>>;
    fn retrieve_slice_hash(
        &self,
        arc: DhtArc,
        slice_index: u64,
    ) -> BoxFuture<'_, K2Result<Option<Bytes>>>;
    fn retrieve_slice_hashes(
        &self,
        arc: DhtArc,
    ) -> BoxFuture<'_, K2Result<Vec<(u64, Bytes)>>>;
}
Expand description

The API that a kitsune2 host must implement to provide data persistence for kitsune2.

Required Methods§

Source

fn process_incoming_ops( &self, op_list: Vec<Bytes>, ) -> BoxFuture<'_, K2Result<Vec<OpId>>>

Process incoming ops.

Pass the incoming ops to the host for processing. The host is expected to store the ops if it is able to process them.

Source

fn retrieve_op_hashes_in_time_slice( &self, arc: DhtArc, start: Timestamp, end: Timestamp, ) -> BoxFuture<'_, K2Result<(Vec<OpId>, u32)>>

Retrieve a batch of ops from the host by time range.

This must be the timestamp of the op, not the time that we saw the op or chose to store it. The returned ops must be ordered by timestamp, ascending.

§Returns
  • As many op ids as can be returned within the limit_bytes limit, within the arc and time bounds.
  • The total size of the op data that is pointed to by the returned op ids.
Source

fn retrieve_ops( &self, op_ids: Vec<OpId>, ) -> BoxFuture<'_, K2Result<Vec<MetaOp>>>

Retrieve a list of ops by their op ids.

This should be used to get op data for ops.

Source

fn filter_out_existing_ops( &self, op_ids: Vec<OpId>, ) -> BoxFuture<'_, K2Result<Vec<OpId>>>

Filter the passed in op ids by ops that exist in the store.

§Returns

The filtered list of op ids that do not exist in the store.

Source

fn retrieve_op_ids_bounded( &self, arc: DhtArc, start: Timestamp, limit_bytes: u32, ) -> BoxFuture<'_, K2Result<(Vec<OpId>, u32, Timestamp)>>

Retrieve a size-bounded list of op ids that have been stored within the given arc since start.

The start timestamp is used to retrieve ops by their stored_at timestamp rather than their creation timestamp. This means that the start value can be used to page an op store.

The limit_bytes applies to the size of the op data, not the size of the op ids. This can be thought of as a “page size” for the op data. Where the size is the size of the data rather than the number of ops.

If the limit is applied, then the timestamp of the last op id is returned. Otherwise, the timestamp for when this operation started is returned. Either way, the returned timestamp should be used as the start value for the next call to this op store.

§Returns
  • As many op ids as can be returned within the limit_bytes limit.
  • The total size of the op data that is pointed to by the returned op ids.
  • A new timestamp to be used for the next query.
Source

fn earliest_timestamp_in_arc( &self, arc: DhtArc, ) -> BoxFuture<'_, K2Result<Option<Timestamp>>>

Get the earliest op timestamp in the given arc.

If there are no ops in the arc, return None. Otherwise, return the earliest created_at timestamp of the ops in the arc.

This is used to determine the earliest timestamp that the arc has seen. That is a lower bound on the work that needs to be done when building a summary model of the DHT.

Source

fn store_slice_hash( &self, arc: DhtArc, slice_index: u64, slice_hash: Bytes, ) -> BoxFuture<'_, K2Result<()>>

Store the combined hash of a time slice.

Source

fn slice_hash_count(&self, arc: DhtArc) -> BoxFuture<'_, K2Result<u64>>

Count the number of stored time slices.

Source

fn retrieve_slice_hash( &self, arc: DhtArc, slice_index: u64, ) -> BoxFuture<'_, K2Result<Option<Bytes>>>

Retrieve the combined hash of a time slice.

If the slice is not found, return None. If the time slice is present, then it must be identical to what was stored by Kitsune2 using Self::store_slice_hash.

Source

fn retrieve_slice_hashes( &self, arc: DhtArc, ) -> BoxFuture<'_, K2Result<Vec<(u64, Bytes)>>>

Retrieve all slice hashes for a given arc.

Implementors§