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§
Sourcefn put(
&self,
peer: Url,
key: String,
value: Bytes,
expiry: Option<Timestamp>,
) -> BoxFuture<'_, K2Result<()>>
fn put( &self, peer: Url, key: String, value: Bytes, expiry: Option<Timestamp>, ) -> BoxFuture<'_, K2Result<()>>
Store a key-value pair for a peer.
Sourcefn get(&self, peer: Url, key: String) -> BoxFuture<'_, K2Result<Option<Bytes>>>
fn get(&self, peer: Url, key: String) -> BoxFuture<'_, K2Result<Option<Bytes>>>
Get a value by key for a peer.
Provided Methods§
Sourcefn set_unresponsive(
&self,
peer: Url,
expiry: Timestamp,
when: Timestamp,
) -> BoxFuture<'_, K2Result<()>>
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.