-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into go-go-gossip
- Loading branch information
Showing
17 changed files
with
382 additions
and
114 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use crate::{builder, config, AgentId, BoxFut, K2Result, SpaceId, Timestamp}; | ||
use futures::future::BoxFuture; | ||
use std::sync::Arc; | ||
|
||
/// A store for peer metadata. | ||
/// | ||
/// This is expected to be backed by a key-value store that keys by space, agent_id and key. | ||
pub trait PeerMetaStore: 'static + Send + Sync + std::fmt::Debug { | ||
/// Store a key-value pair for a given space and agent. | ||
fn put( | ||
&self, | ||
space: SpaceId, | ||
agent: AgentId, | ||
key: String, | ||
value: bytes::Bytes, | ||
expiry: Option<Timestamp>, | ||
) -> BoxFuture<'_, K2Result<()>>; | ||
|
||
/// Get a value by key for a given space and agent. | ||
fn get( | ||
&self, | ||
space: SpaceId, | ||
agent: AgentId, | ||
key: String, | ||
) -> BoxFuture<'_, K2Result<Option<bytes::Bytes>>>; | ||
|
||
/// Delete a key-value pair for a given space and agent. | ||
fn delete( | ||
&self, | ||
space: SpaceId, | ||
agent: AgentId, | ||
key: String, | ||
) -> BoxFuture<'_, K2Result<()>>; | ||
} | ||
|
||
/// Trait-object version of kitsune2 [PeerMetaStore]. | ||
pub type DynPeerMetaStore = Arc<dyn PeerMetaStore>; | ||
|
||
/// A factory for constructing [PeerMetaStore] instances. | ||
pub trait PeerMetaStoreFactory: | ||
'static + Send + Sync + std::fmt::Debug | ||
{ | ||
/// Help the builder construct a default config from the chosen | ||
/// module factories. | ||
fn default_config(&self, config: &mut config::Config) -> K2Result<()>; | ||
|
||
/// Construct a meta store instance. | ||
fn create( | ||
&self, | ||
builder: Arc<builder::Builder>, | ||
) -> BoxFut<'static, K2Result<DynPeerMetaStore>>; | ||
} | ||
|
||
/// Trait-object [PeerMetaStoreFactory]. | ||
pub type DynPeerMetaStoreFactory = Arc<dyn PeerMetaStoreFactory>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.