mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-04 05:31:32 +00:00
krata: rework xenstore watch for reliability
This commit is contained in:
@ -192,19 +192,23 @@ impl XsdClient {
|
||||
response.parse_bool()
|
||||
}
|
||||
|
||||
pub async fn watch<P: AsRef<str>>(&self, path: P) -> Result<XsdWatchHandle> {
|
||||
pub async fn create_watch(&self) -> Result<XsdWatchHandle> {
|
||||
let (id, receiver, unwatch_sender) = self.socket.add_watch().await?;
|
||||
let id_string = id.to_string();
|
||||
let _ = self
|
||||
.socket
|
||||
.send(0, XSD_WATCH, &[path.as_ref(), &id_string])
|
||||
.await?;
|
||||
Ok(XsdWatchHandle {
|
||||
id,
|
||||
receiver,
|
||||
unwatch_sender,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn bind_watch<P: AsRef<str>>(&self, handle: &XsdWatchHandle, path: P) -> Result<()> {
|
||||
let id_string = handle.id.to_string();
|
||||
let _ = self
|
||||
.socket
|
||||
.send(0, XSD_WATCH, &[path.as_ref(), &id_string])
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
Reference in New Issue
Block a user