pub trait Space:
'static
+ Send
+ Sync
+ Debug {
// Required methods
fn peer_store(&self) -> &DynPeerStore;
fn local_agent_store(&self) -> &DynLocalAgentStore;
fn op_store(&self) -> &DynOpStore;
fn fetch(&self) -> &DynFetch;
fn publish(&self) -> &DynPublish;
fn gossip(&self) -> &DynGossip;
fn peer_meta_store(&self) -> &DynPeerMetaStore;
fn current_url(&self) -> Option<Url>;
fn local_agent_join(
&self,
local_agent: DynLocalAgent,
) -> BoxFut<'_, K2Result<()>>;
fn local_agent_leave(&self, local_agent: AgentId) -> BoxFut<'_, ()>;
fn send_notify(&self, to_peer: Url, data: Bytes) -> BoxFut<'_, K2Result<()>>;
fn inform_ops_stored(&self, ops: Vec<StoredOp>) -> BoxFut<'_, K2Result<()>>;
}Expand description
Represents a unique dht space within which to communicate with peers.
A space in Kitsune2 is largely just responsible for hooking up modules within that space. However, it also has a couple responsibilities:
- The space provides the space-level notification send/recv ability.
- The space manages the generation / publishing of agent infos for joined local agents.
Required Methods§
Sourcefn peer_store(&self) -> &DynPeerStore
fn peer_store(&self) -> &DynPeerStore
Get a reference to the peer store being used by this space. This could allow you to inject peer info from some source other than gossip or bootstrap, or to query the store directly if you have a need to determine peers for direct messaging.
Sourcefn local_agent_store(&self) -> &DynLocalAgentStore
fn local_agent_store(&self) -> &DynLocalAgentStore
Get a reference to the local agent store being used by this space.
Sourcefn op_store(&self) -> &DynOpStore
fn op_store(&self) -> &DynOpStore
Get a reference to the op store of this space. Ops can be injected and retrieved from the op store.
Sourcefn publish(&self) -> &DynPublish
fn publish(&self) -> &DynPublish
get a reference to the publish module of this space.
Sourcefn peer_meta_store(&self) -> &DynPeerMetaStore
fn peer_meta_store(&self) -> &DynPeerMetaStore
Get a reference to the peer meta store being used by this space.
Sourcefn current_url(&self) -> Option<Url>
fn current_url(&self) -> Option<Url>
The URL that this space is currently reachable at, if any.
Sourcefn local_agent_join(
&self,
local_agent: DynLocalAgent,
) -> BoxFut<'_, K2Result<()>>
fn local_agent_join( &self, local_agent: DynLocalAgent, ) -> BoxFut<'_, K2Result<()>>
Indicate that an agent is now online, and should begin receiving messages and exchanging dht information.
Sourcefn local_agent_leave(&self, local_agent: AgentId) -> BoxFut<'_, ()>
fn local_agent_leave(&self, local_agent: AgentId) -> BoxFut<'_, ()>
Indicate that an agent is no longer online, and should stop receiving messages and exchanging dht information. Before the agent is actually removed a tombstone agent info will be generated and sent to the bootstrap server. A best effort will be made to publish this tombstone to peers in the space as well.
Sourcefn send_notify(&self, to_peer: Url, data: Bytes) -> BoxFut<'_, K2Result<()>>
fn send_notify(&self, to_peer: Url, data: Bytes) -> BoxFut<'_, K2Result<()>>
Send a message to a remote peer. The future returned from this function will track the message all the way down to the low-level network transport implementation. But once the data is handed off there, this function will return Ok, and you will not know if the remote has received it or not.
Sourcefn inform_ops_stored(&self, ops: Vec<StoredOp>) -> BoxFut<'_, K2Result<()>>
fn inform_ops_stored(&self, ops: Vec<StoredOp>) -> BoxFut<'_, K2Result<()>>
Inform the space that a set of ops have been stored.
This should be called once the ops have been:
- Checked to be correctly structured according to the Kitsune2 host implementation.
- Persisted to the op store.
Until this is called, gossip will not include these ops in its DHT model, and they will therefore not be synced with other peers. They may be synced with other peers through the “new ops” mechanism, depending on the op store implementation, but that only makes them available briefly.