pub struct Engine<D> {
pub endpoint: Endpoint,
pub sync: SyncHandle,
pub default_author: Arc<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: Connecting) -> Result<()>
pub async fn handle_connection(&self, conn: Connecting) -> 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
.
source§impl<D: Store> Engine<D>
impl<D: Store> Engine<D>
sourcepub fn client(&self) -> &MemClient
Available on crate feature rpc
only.
pub fn client(&self) -> &MemClient
rpc
only.Get an in memory client to interact with the docs engine.
sourcepub async fn handle_rpc_request<C: ChannelTypes<RpcService>>(
self,
msg: Request,
chan: RpcChannel<RpcService, C>
) -> Result<(), RpcServerError<C>>
Available on crate feature rpc
only.
pub async fn handle_rpc_request<C: ChannelTypes<RpcService>>( self, msg: Request, chan: RpcChannel<RpcService, C> ) -> Result<(), RpcServerError<C>>
rpc
only.Handle a docs request from the RPC server.