pub struct Engine<D> {
pub endpoint: Endpoint,
pub sync: SyncHandle,
pub default_author: DefaultAuthor,
/* private fields */
}
engine
only.Expand description
The sync engine coordinates actors that manage open documents, set-reconciliation syncs with peers and a gossip swarm for each syncing document.
Fields§
§endpoint: Endpoint
[Endpoint
] used by the engine.
sync: SyncHandle
Handle to the actor thread.
The persistent default author for this engine.
Implementations§
Source§impl<D: Store> Engine<D>
impl<D: Store> Engine<D>
Sourcepub async fn spawn(
endpoint: Endpoint,
gossip: Gossip,
replica_store: Store,
bao_store: D,
downloader: Downloader,
default_author_storage: DefaultAuthorStorage,
local_pool_handle: LocalPoolHandle,
) -> Result<Self>
pub async fn spawn( endpoint: Endpoint, gossip: Gossip, replica_store: Store, bao_store: D, downloader: Downloader, default_author_storage: DefaultAuthorStorage, local_pool_handle: LocalPoolHandle, ) -> Result<Self>
Start the sync engine.
This will spawn two tokio tasks for the live sync coordination and gossip actors, and a
thread for the crate::actor::SyncHandle
.
Sourcepub fn protect_cb(&self) -> ProtectCb
pub fn protect_cb(&self) -> ProtectCb
Return a callback that can be added to blobs to protect the content of all docs from garbage collection.
Sourcepub fn blob_store(&self) -> &D
pub fn blob_store(&self) -> &D
Get the blob store.
Sourcepub async fn start_sync(
&self,
namespace: NamespaceId,
peers: Vec<NodeAddr>,
) -> Result<()>
pub async fn start_sync( &self, namespace: NamespaceId, peers: Vec<NodeAddr>, ) -> Result<()>
Start to sync a document.
If peers
is non-empty, it will both do an initial set-reconciliation sync with each peer,
and join an iroh-gossip swarm with these peers to receive and broadcast document updates.
Sourcepub async fn leave(
&self,
namespace: NamespaceId,
kill_subscribers: bool,
) -> Result<()>
pub async fn leave( &self, namespace: NamespaceId, kill_subscribers: bool, ) -> Result<()>
Stop the live sync for a document and leave the gossip swarm.
If kill_subscribers
is true, all existing event subscribers will be dropped. This means
they will receive None
and no further events in case of rejoining the document.
Sourcepub async fn subscribe(
&self,
namespace: NamespaceId,
) -> Result<impl Stream<Item = Result<LiveEvent>> + Unpin + 'static>
pub async fn subscribe( &self, namespace: NamespaceId, ) -> Result<impl Stream<Item = Result<LiveEvent>> + Unpin + 'static>
Subscribe to replica and sync progress events.
Sourcepub async fn handle_connection(&self, conn: Connection) -> Result<()>
pub async fn handle_connection(&self, conn: Connection) -> Result<()>
Handle an incoming iroh-docs connection.
Sourcepub fn local_pool_handle(&self) -> &LocalPoolHandle
pub fn local_pool_handle(&self) -> &LocalPoolHandle
Returns the stored LocalPoolHandle
.