Compare commits
No commits in common. "15bb446aa413362347d091bd5e963fb494f0bba4" and "08ca2483e1a3ad11ae05fd313002d88f04caf85f" have entirely different histories.
15bb446aa4
...
08ca2483e1
|
|
@ -7,19 +7,6 @@ use std::sync::Arc;
|
|||
use tokio::sync::mpsc;
|
||||
use tokio::time::Duration;
|
||||
|
||||
/// # Fn `create_watcher`
|
||||
/// ## for creating watcher on file's delete | update events
|
||||
///
|
||||
/// *input* : `&str`, `&str`
|
||||
///
|
||||
/// *output* : `Err` if it cant create file watcher | `Ok(watcher)` on successfull construction
|
||||
///
|
||||
/// *initiator* : fn `file_handler`, fn `utils::run_daemons`
|
||||
///
|
||||
/// *managing* : current file's name: &str, path in local storage to current file: &str
|
||||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
pub async fn create_watcher(filename: &str, path: &str) -> Result<Inotify, std::io::Error> {
|
||||
let src = format!("{}{}", path, filename);
|
||||
let inotify: Inotify = Inotify::init()?;
|
||||
|
|
@ -27,19 +14,6 @@ pub async fn create_watcher(filename: &str, path: &str) -> Result<Inotify, std::
|
|||
Ok(inotify)
|
||||
}
|
||||
|
||||
/// # Fn `create_watcher`
|
||||
/// ## for managing processes by checking dep files' states
|
||||
///
|
||||
/// *input* : `&str`, `&[Files]`, `Arc<mpsc::Sender<u8>>`, `Arc<tokio::sync::Mutex<Vec<Inotify>>>`
|
||||
///
|
||||
/// *output* : `Err` if something with dep file is wrong | `Ok(())` on successfull dep file check
|
||||
///
|
||||
/// *initiator* : fn `utils::running_handler`
|
||||
///
|
||||
/// *managing* : current process's name: &str, list of dep files : `&[Files]`, atomic ref counter on sender main channel for current process `Arc<mpsc::Sender<u8>>`, mut list of file watchers`Arc<tokio::sync::Mutex<Vec<Inotify>>>`
|
||||
///
|
||||
/// *depends on* : Files
|
||||
///
|
||||
pub async fn file_handler(
|
||||
name: &str,
|
||||
files: &[Files],
|
||||
|
|
@ -123,19 +97,6 @@ pub async fn file_handler(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// # Fn `check_file`
|
||||
/// ## for checking existance of current file
|
||||
///
|
||||
/// *input* : `&str`, `&str`
|
||||
///
|
||||
/// *output* : `Ok(())` if file exists | `Err(_)` if not | panic on fs error
|
||||
///
|
||||
/// *initiator* : fn `file_handler`
|
||||
///
|
||||
/// *managing* : current file's name: `&str` and current file's path in local storage: `&str`
|
||||
///
|
||||
/// *depends on* : network activity
|
||||
///
|
||||
pub async fn check_file(filename: &str, path: &str) -> Result<(), CustomError> {
|
||||
let arc_name = Arc::new(filename.to_string());
|
||||
let arc_path = Arc::new(path.to_string());
|
||||
|
|
|
|||
|
|
@ -1,37 +1,12 @@
|
|||
// 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<UnixStream, std::io::Error> {
|
||||
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() {
|
||||
|
|
@ -44,19 +19,7 @@ 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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue