Skip to content

Commit

Permalink
docs: add general documentation to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Feb 21, 2024
1 parent 4885fb2 commit d499caf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ use tonic::{

use futures::FutureExt;

/// The gRPC service used to forward message to their respective module.
pub struct ForwarderService {
/// A list of active modules.
command_map: Mutex<HashMap<String, Channel>>,
/// The path to search for modules. For security this is a single path.
search_path: PathBuf,
// The sender used to transmit data back to the client.
tx: tokio::sync::mpsc::UnboundedSender<()>,
}

Expand All @@ -45,7 +49,9 @@ impl Forwarder for ForwarderService {
) -> Result<Response<Self::ForwardStream>, Status> {
let invocation = request.into_inner();

let _ = self.tx.send(());
self.tx
.send(())
.map_err(|err| Status::new(Code::Internal, err.to_string()))?;

let module = {
let command_map = &mut self.command_map.lock().await;
Expand Down Expand Up @@ -152,10 +158,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}

// Drain the remaining messages.
while rx.recv().now_or_never().is_some() {};
while rx.recv().now_or_never().is_some() {}
}
});

// The ready message is sent to stdout. It allows for clients to properly synchronize with the
// server upon startup.
println!("ready");

Server::builder()
Expand Down
2 changes: 1 addition & 1 deletion src/subprocess.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This file manages the handling of modules (subprocesses)
//! Manages the handling of modules (subprocesses).
use anyhow::Result;
use std::path::PathBuf;
Expand Down

0 comments on commit d499caf

Please sign in to comment.