pub struct Engine {
pub endpoint: Endpoint,
pub sync: SyncHandle,
pub default_author: DefaultAuthor,
/* private fields */
}
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 Engine
impl Engine
Sourcepub async fn spawn(
endpoint: Endpoint,
gossip: Gossip,
replica_store: Store,
bao_store: Store,
downloader: Downloader,
default_author_storage: DefaultAuthorStorage,
protect_cb: Option<ProtectCallbackHandler>,
) -> Result<Self>
pub async fn spawn( endpoint: Endpoint, gossip: Gossip, replica_store: Store, bao_store: Store, downloader: Downloader, default_author_storage: DefaultAuthorStorage, protect_cb: Option<ProtectCallbackHandler>, ) -> 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 actor interacting with doc storage.
Sourcepub fn blob_store(&self) -> &Store
pub fn blob_store(&self) -> &Store
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.