docs: services + prcs fix

pull/7/head
prplV 2024-11-13 15:29:00 +03:00
parent c14a6f943b
commit adb3858ee4
2 changed files with 44 additions and 5 deletions

View File

@ -108,7 +108,7 @@ pub async fn is_frozen(name: &str) -> bool {
///
/// *input* : `&str`
///
/// *output* : -
/// *output* : ()
///
/// *initiator* : fn `utils::files::file_handler`, fn `utils::files::service_handler`, fn `utils::run_daemons`
///
@ -131,7 +131,7 @@ pub async fn terminate_process(name: &str) {
///
/// *input* : `&str`
///
/// *output* : -
/// *output* : ()
///
/// *initiator* : fn `utils::run_daemons`
///
@ -154,7 +154,7 @@ pub async fn freeze_process(name: &str) {
///
/// *input* : `&str`
///
/// *output* : -
/// *output* : ()
///
/// *initiator* : fn `utils::run_daemons`
///
@ -177,7 +177,7 @@ pub async fn unfreeze_process(name: &str) {
///
/// *input* : `&str`, &str
///
/// *output* : -
/// *output* : ()
///
/// *initiator* : fn `utils::run_daemons`
///
@ -196,7 +196,7 @@ pub async fn restart_process(name: &str, path: &str) -> Result<(), CustomError>
///
/// *input* : `&str`, &str
///
/// *output* : -
/// *output* : ()
///
/// *initiator* : fn `restart_process`
///

View File

@ -6,6 +6,19 @@ use std::sync::Arc;
use tokio::sync::mpsc;
use tokio::time::{Duration, Instant};
/// # Fn `service_handler`
/// ## function to realize mechanism of current process' dep services monitoring
///
/// *input* : `&str`, `&Vec<Services>`, `Arc<mpsc::Sender<u8>>`
///
/// *output* : ()
///
/// *initiator* : fn `utils::running_handler`
///
/// *managing* : process name, ref of vec of dep services, ref counter to managing channel writer
///
/// *depends on* : fn `check_service`, fn `utils::prcs::is_active`, fn `utils::prcs::is_frozen`, fn `looped_service_connecting`
///
pub async fn service_handler(
name: &str,
services: &Vec<Services>,
@ -54,6 +67,19 @@ pub async fn service_handler(
Ok(())
}
/// # Fn `looped_service_connecting`
/// ## for service's state check in loop (with delay and restriction of attempts)
///
/// *input* : `&str`, `&Services`
///
/// *output* : Ok(()) if service now available | Err(er) if still not
///
/// *initiator* : fn `service_handler`
///
/// *managing* : process name, current service struct
///
/// *depends on* : fn `check_service`
///
async fn looped_service_connecting(name: &str, serv: &Services) -> Result<(), CustomError> {
if serv.triggers.wait == 0 {
loop {
@ -103,6 +129,19 @@ async fn looped_service_connecting(name: &str, serv: &Services) -> Result<(), Cu
}
}
/// # Fn `check_service`
/// ## for check current service's availiability
///
/// *input* : `&str`, `&u32`
///
/// *output* : Ok(()) if service now available | Err(er) if still not
///
/// *initiator* : fn `service_handler`, fn `looped_service_connecting`
///
/// *managing* : hostname, port
///
/// *depends on* : -
///
// ! have to be rewritten
// todo: rewrite use
async fn check_service(hostname: &str, port: &u32) -> Result<(), CustomError> {