trifid/tfclient/src/nebulaworker.rs

34 lines
1.0 KiB
Rust
Raw Normal View History

2023-03-22 18:34:06 +00:00
// Code to handle the nebula worker
use std::sync::mpsc::{Receiver, TryRecvError};
use log::{error, info};
2023-03-22 18:34:06 +00:00
use crate::config::TFClientConfig;
use crate::daemon::ThreadMessageSender;
pub enum NebulaWorkerMessage {
Shutdown
2023-03-22 18:34:06 +00:00
}
pub fn nebulaworker_main(_config: TFClientConfig, _transmitter: ThreadMessageSender, rx: Receiver<NebulaWorkerMessage>) {
loop {
match rx.try_recv() {
Ok(msg) => {
match msg {
NebulaWorkerMessage::Shutdown => {
info!("recv on command socket: shutdown, stopping");
break;
}
}
},
Err(e) => {
match e {
TryRecvError::Empty => {}
TryRecvError::Disconnected => {
error!("nebulaworker command socket disconnected, shutting down to prevent orphaning");
break;
}
}
}
}
}
}