diff --git a/src/utils/hagent.rs b/src/utils/hagent.rs index 6e5910f..c794538 100644 --- a/src/utils/hagent.rs +++ b/src/utils/hagent.rs @@ -1,12 +1,37 @@ // module needed to check host-agent health condition and to communicate with it -/// asdasdasds use tokio::{io::Interest, net::UnixStream}; +/// # Fn `open_unix_socket` +/// ## opening unix-socket for host-agent communication +/// +/// *input* : - +/// +/// *output* : `Ok(socket)` if socket was successfully opened | `Err(er)` if not +/// +/// *initiator* : main thread `(??)` +/// +/// *managing* : - +/// +/// *depends on* : - +/// async fn open_unix_socket() -> Result { let socket = UnixStream::connect("/var/run/enode/hostagent.sock").await?; Ok(socket) } +/// # Fn `ha_healthcheck` +/// ## for checking host-agent state +/// +/// *input* : `&UnixStream` +/// +/// *output* : `Ok(()))` if host-agent is running | `Err(er)` if not +/// +/// *initiator* : main thread `(??)` +/// +/// *managing* : ref on unix-socket object +/// +/// *depends on* : - +/// async fn ha_healthcheck(socket: &UnixStream) -> Result<(), std::io::Error >{ socket.ready(Interest::WRITABLE).await?; if socket.writable().await.is_ok() { @@ -19,7 +44,19 @@ async fn ha_healthcheck(socket: &UnixStream) -> Result<(), std::io::Error >{ Ok(()) } - +/// # Fn `ha_healthcheck` +/// ## for sending data to host-agent using unix-socket +/// +/// *input* : `&UnixStream`, `&str` +/// +/// *output* : `Ok(()))` if data was sent| `Err(er)` if not +/// +/// *initiator* : main thread `(??)` +/// +/// *managing* : socket: `&UnixStream`, data: `&str` +/// +/// *depends on* : - +/// async fn ha_send_data(socket: &UnixStream, data: &str) -> Result<(), std::io::Error > { socket.ready(Interest::WRITABLE).await?; if socket.writable().await.is_ok() {