krata: rework xenstore watch for reliability

This commit is contained in:
Alex Zenla
2024-03-23 08:46:20 +00:00
parent 3d5095c78b
commit 7b2de22320
4 changed files with 64 additions and 35 deletions

View File

@ -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)]