PeerMetaStore

Trait PeerMetaStore 

Source
pub trait PeerMetaStore:
    'static
    + Send
    + Sync
    + Debug {
    // Required methods
    fn put(
        &self,
        peer: Url,
        key: String,
        value: Bytes,
        expiry: Option<Timestamp>,
    ) -> BoxFuture<'_, K2Result<()>>;
    fn get(
        &self,
        peer: Url,
        key: String,
    ) -> BoxFuture<'_, K2Result<Option<Bytes>>>;
    fn get_all_by_key(
        &self,
        key: String,
    ) -> BoxFuture<'_, K2Result<HashMap<Url, Bytes>>>;
    fn delete(&self, peer: Url, key: String) -> BoxFuture<'_, K2Result<()>>;

    // Provided methods
    fn set_unresponsive(
        &self,
        peer: Url,
        expiry: Timestamp,
        when: Timestamp,
    ) -> BoxFuture<'_, K2Result<()>> { ... }
    fn get_unresponsive(
        &self,
        peer: Url,
    ) -> BoxFuture<'_, K2Result<Option<Timestamp>>> { ... }
}
Expand description

A store for peer metadata.

This is expected to be backed by a key-value store that keys by space, peer URL and key.

Required Methods§

Source

fn put( &self, peer: Url, key: String, value: Bytes, expiry: Option<Timestamp>, ) -> BoxFuture<'_, K2Result<()>>

Store a key-value pair for a peer.

Source

fn get(&self, peer: Url, key: String) -> BoxFuture<'_, K2Result<Option<Bytes>>>

Get a value by key for a peer.

Source

fn get_all_by_key( &self, key: String, ) -> BoxFuture<'_, K2Result<HashMap<Url, Bytes>>>

Get all peer urls and values for a given key.

Source

fn delete(&self, peer: Url, key: String) -> BoxFuture<'_, K2Result<()>>

Delete a key-value pair for a given space and peer.

Provided Methods§

Source

fn set_unresponsive( &self, peer: Url, expiry: Timestamp, when: Timestamp, ) -> BoxFuture<'_, K2Result<()>>

Mark a peer url unresponsive with an expiration timestamp.

The value that will be stored with the peer key is the passed in timestamp from when the URL became unresponsive.

After the expiry timestamp has passed, the peer url is supposed to be removed from the store.

Source

fn get_unresponsive( &self, peer: Url, ) -> BoxFuture<'_, K2Result<Option<Timestamp>>>

Get the timestamp of when a peer URL last was marked unresponsive, if it is present in the store.

Implementors§