Compare commits

1 Commits

Author SHA1 Message Date
Micheal Smith
27ad93d749 Adding response FIFO. 2025-11-12 05:56:07 -06:00
3 changed files with 38 additions and 3 deletions

13
Cargo.lock generated
View File

@@ -1401,6 +1401,18 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nix"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@@ -1973,6 +1985,7 @@ dependencies = [
"genai", "genai",
"human-panic", "human-panic",
"irc", "irc",
"nix",
"rstest", "rstest",
"serde", "serde",
"serde_json", "serde_json",

View File

@@ -15,6 +15,10 @@ serde_json = "1.0"
tracing = "0.1" tracing = "0.1"
tracing-subscriber = "0.3" tracing-subscriber = "0.3"
[dependencies.nix]
version = "0.30.1"
features = [ "fs" ]
[dependencies.clap] [dependencies.clap]
version = "4.5" version = "4.5"
features = [ "derive" ] features = [ "derive" ]

View File

@@ -1,9 +1,15 @@
use std::{collections::VecDeque, path::Path, sync::Arc}; use std::{collections::VecDeque, path::Path, sync::Arc};
use color_eyre::Result; use color_eyre::Result;
//use nix::{NixPath, sys::stat, unistd::mkfifo};
use tokio::{ use tokio::{
// fs::File,
io::AsyncWriteExt, io::AsyncWriteExt,
net::{UnixListener, UnixStream}, net::{
UnixListener,
UnixStream,
// unix::pipe::{self, Receiver},
},
sync::{RwLock, broadcast}, sync::{RwLock, broadcast},
}; };
use tracing::{error, info}; use tracing::{error, info};
@@ -46,8 +52,20 @@ impl EventManager {
Ok(()) Ok(())
} }
pub async fn start_listening(self: Arc<Self>, path: impl AsRef<Path>) { // NB: This assumes it has exclusive control of the FIFO.
let listener = UnixListener::bind(path).unwrap(); // async fn start_fifo<P>(path: &P) -> Result<()>
// where
// P: AsRef<Path> + NixPath + ?Sized,
// {
// // Just delete the old FIFO if it exists.
// let _ = std::fs::remove_file(path);
// mkfifo(path, stat::Mode::S_IRWXU)?;
// Ok(())
// }
pub async fn start_listening(self: Arc<Self>, broadcast_path: impl AsRef<Path>) {
let listener = UnixListener::bind(broadcast_path).unwrap();
loop { loop {
match listener.accept().await { match listener.accept().await {