added config doc-comments
test-org/integration-module/pipeline/pr-rc This commit looks good
Details
test-org/integration-module/pipeline/pr-rc This commit looks good
Details
parent
8e32de3be3
commit
9499c97ce6
|
|
@ -15,6 +15,20 @@ const CONFIG_PATH: &str = "config_api.json";
|
|||
const SOCKET_PATH: &str = "api-grub.sock";
|
||||
|
||||
// TODO: rewrite to use current_exe
|
||||
/// # Fn `pull_local_config`
|
||||
///
|
||||
/// ## function to one-time pulling local config by straight reading
|
||||
///
|
||||
/// ### Dev-Info :
|
||||
///
|
||||
/// *input* : -
|
||||
///
|
||||
/// *output* : `anyhow::Result<integr_structs::api::v3::Config>`
|
||||
///
|
||||
/// *initiator* : fn `main`
|
||||
///
|
||||
/// *managing* : -
|
||||
///
|
||||
pub async fn pull_local_config() -> Result<Config> {
|
||||
let path = Path::new(CONFIG_PATH);
|
||||
if path.exists() && path.is_file() {
|
||||
|
|
@ -28,6 +42,22 @@ pub async fn pull_local_config() -> Result<Config> {
|
|||
}
|
||||
|
||||
// for config pulling
|
||||
/// # Fn `pull_local_config`
|
||||
///
|
||||
/// ## function to init Unix-Socket listening for grabbing new configs
|
||||
///
|
||||
/// ### Dev-Info :
|
||||
///
|
||||
/// *input* : `&tokio::sync::mpsc::Sender<integr_structs::api::v3::Config>`
|
||||
///
|
||||
/// *output* : `anyhow::Result<()>`
|
||||
///
|
||||
/// *initiator* : fn `main`
|
||||
///
|
||||
/// *managing* : -
|
||||
///
|
||||
/// *depends on* : `const SOCKET_PATH`
|
||||
///
|
||||
pub async fn init_config_grub_mechanism(tx: &Sender<Config>) -> Result<()> {
|
||||
info!("Initializing Unix-Socket listening for pulling new configs...");
|
||||
let server = init_unix_listener().await?;
|
||||
|
|
@ -57,12 +87,43 @@ pub async fn init_config_grub_mechanism(tx: &Sender<Config>) -> Result<()> {
|
|||
}
|
||||
|
||||
// saving new config locally
|
||||
/// # Fn `save_new_config`
|
||||
///
|
||||
/// ## function for saving new config locally
|
||||
///
|
||||
/// ### Dev-Info :
|
||||
///
|
||||
/// *input* : `&String | &str`
|
||||
///
|
||||
/// *output* : `anyhow::Result<()>`
|
||||
///
|
||||
/// *initiator* : fn `main`
|
||||
///
|
||||
/// *managing* : -
|
||||
///
|
||||
/// *depends on* : `const CONFIG_PATH`
|
||||
///
|
||||
async fn save_new_config(config: &String) -> Result<()> {
|
||||
fs::write(CONFIG_PATH, config)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// # Fn `pull_local_config`
|
||||
///
|
||||
/// ## function for saving new config locally
|
||||
///
|
||||
/// ### Dev-Info :
|
||||
///
|
||||
/// *input* : `&tokio::sync::mpsc::Sender<Config>`
|
||||
///
|
||||
/// *output* : `anyhow::Result<tokio::net::UnixListener>`
|
||||
///
|
||||
/// *initiator* : fn `init_config_grub_mechanism`
|
||||
///
|
||||
/// *managing* : -
|
||||
///
|
||||
/// *depends on* : `const SOCKET_PATH`
|
||||
///
|
||||
async fn init_unix_listener() -> Result<UnixListener> {
|
||||
let _ = fs::remove_file(SOCKET_PATH);
|
||||
Ok(UnixListener::bind(SOCKET_PATH)?)
|
||||
|
|
|
|||
Loading…
Reference in New Issue