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: SyncHandleHandle 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<EndpointAddr>,
) -> Result<()>
pub async fn start_sync( &self, namespace: NamespaceId, peers: Vec<EndpointAddr>, ) -> 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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more