Struct iroh_docs::actor::SyncHandle
source · pub struct SyncHandle { /* private fields */ }
Expand description
The SyncHandle
controls an actor thread which executes replica and store operations.
The SyncHandle
exposes async methods which all send messages into the actor thread, usually
returning something via a return channel. The actor thread itself is a regular std::thread
which processes incoming messages sequentially.
The handle is cheaply cloneable. Once the last clone is dropped, the actor thread is joined.
The thread will finish processing all messages in the channel queue, and then exit.
To prevent this last drop from blocking the calling thread, you can call SyncHandle::shutdown
and await its result before dropping the last SyncHandle
. This ensures that
waiting for the actor to finish happens in an async context, and therefore that the final
SyncHandle::drop
will not block.
Implementations§
source§impl SyncHandle
impl SyncHandle
sourcepub fn spawn(
store: Store,
content_status_callback: Option<ContentStatusCallback>,
me: String
) -> SyncHandle
pub fn spawn( store: Store, content_status_callback: Option<ContentStatusCallback>, me: String ) -> SyncHandle
Spawn a sync actor and return a handle.
pub async fn open(&self, namespace: NamespaceId, opts: OpenOpts) -> Result<()>
pub async fn close(&self, namespace: NamespaceId) -> Result<bool>
pub async fn subscribe( &self, namespace: NamespaceId, sender: Sender<Event> ) -> Result<()>
pub async fn unsubscribe( &self, namespace: NamespaceId, sender: Sender<Event> ) -> Result<()>
pub async fn set_sync(&self, namespace: NamespaceId, sync: bool) -> Result<()>
pub async fn insert_local( &self, namespace: NamespaceId, author: AuthorId, key: Bytes, hash: Hash, len: u64 ) -> Result<()>
pub async fn delete_prefix( &self, namespace: NamespaceId, author: AuthorId, key: Bytes ) -> Result<usize>
pub async fn insert_remote( &self, namespace: NamespaceId, entry: SignedEntry, from: PeerIdBytes, content_status: ContentStatus ) -> Result<()>
pub async fn sync_initial_message( &self, namespace: NamespaceId ) -> Result<Message<SignedEntry>>
pub async fn sync_process_message( &self, namespace: NamespaceId, message: Message<SignedEntry>, from: PeerIdBytes, state: SyncOutcome ) -> Result<(Option<Message<SignedEntry>>, SyncOutcome)>
pub async fn get_sync_peers( &self, namespace: NamespaceId ) -> Result<Option<Vec<PeerIdBytes>>>
pub async fn register_useful_peer( &self, namespace: NamespaceId, peer: PeerIdBytes ) -> Result<()>
pub async fn has_news_for_us( &self, namespace: NamespaceId, heads: AuthorHeads ) -> Result<Option<NonZeroU64>>
pub async fn get_many( &self, namespace: NamespaceId, query: Query, reply: Sender<Result<SignedEntry>> ) -> Result<()>
pub async fn get_exact( &self, namespace: NamespaceId, author: AuthorId, key: Bytes, include_empty: bool ) -> Result<Option<SignedEntry>>
pub async fn drop_replica(&self, namespace: NamespaceId) -> Result<()>
pub async fn export_secret_key( &self, namespace: NamespaceId ) -> Result<NamespaceSecret>
pub async fn get_state(&self, namespace: NamespaceId) -> Result<OpenState>
pub async fn shutdown(&self) -> Result<Store>
pub async fn list_replicas( &self, reply: Sender<Result<(NamespaceId, CapabilityKind)>> ) -> Result<()>
Imports the given author.
Warning: The Author
struct contains sensitive data.
pub async fn import_namespace( &self, capability: Capability ) -> Result<NamespaceId>
pub async fn get_download_policy( &self, namespace: NamespaceId ) -> Result<DownloadPolicy>
pub async fn set_download_policy( &self, namespace: NamespaceId, policy: DownloadPolicy ) -> Result<()>
pub async fn content_hashes(&self) -> Result<ContentHashesIterator>
sourcepub async fn flush_store(&self) -> Result<()>
pub async fn flush_store(&self) -> Result<()>
Makes sure that all pending database operations are persisted to disk.
Otherwise, database operations are batched into bigger transactions for speed. Use this if you need to make sure something is written to the database before another operation, e.g. to make sure sudden process exits don’t corrupt your application state.
It’s not necessary to call this function before shutdown, as shutdown
will
trigger a flush on its own.
Trait Implementations§
source§impl Clone for SyncHandle
impl Clone for SyncHandle
source§fn clone(&self) -> SyncHandle
fn clone(&self) -> SyncHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more