krata: reorganize crates

This commit is contained in:
Alex Zenla
2024-03-07 18:12:47 +00:00
parent c0eeab4047
commit 7bc0c95f00
97 changed files with 24 additions and 24 deletions

View File

@ -0,0 +1,35 @@
use std::env::args;
use xenstore::client::{XsdClient, XsdInterface};
use xenstore::error::Result;
async fn list_recursive(client: &XsdClient, path: &str) -> Result<()> {
let mut pending = vec![path.to_string()];
while let Some(ref path) = pending.pop() {
let children = client.list(path).await?;
for child in children {
let full = format!("{}/{}", if path == "/" { "" } else { path }, child);
let value = client
.read_string(full.as_str())
.await?
.expect("expected value");
println!("{} = {:?}", full, value,);
pending.push(full);
}
}
Ok(())
}
#[tokio::main]
async fn main() -> Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
let client = XsdClient::open().await?;
loop {
list_recursive(&client, "/").await?;
if args().nth(1).unwrap_or("none".to_string()) != "stress" {
break;
}
}
Ok(())
}

View File

@ -0,0 +1,23 @@
use std::env::args;
use xenstore::client::XsdClient;
use xenstore::error::Result;
#[tokio::main]
async fn main() -> Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
let path = args().nth(1).unwrap_or("/local/domain".to_string());
let client = XsdClient::open().await?;
let mut handle = client.watch(&path).await?;
let mut count = 0;
loop {
let Some(event) = handle.receiver.recv().await else {
break;
};
println!("{}", event);
count += 1;
if count >= 3 {
break;
}
}
Ok(())
}