Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
WIP: Test sending a message over socket
Browse files Browse the repository at this point in the history
Blocks on something, doesn’t print to stderr :(
  • Loading branch information
Profpatsch committed May 14, 2019
1 parent 8d06cda commit f95f17c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/ops/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ use std::path::PathBuf;
use std::sync::mpsc;
use std::thread;

const SOCKET_FILE_NAME: &'static str = "/tmp/lorri-socket";

// TODO: make private again
/// Instructs the daemon to start a build
struct StartBuild {
pub struct StartBuild {
nix_file: PathBuf,
}

/// See the documentation for lorri::cli::Command::Shell for more
/// details.
pub fn main() -> OpResult {
let listener = listener::Listener::new(Path::new("/tmp/lorri-socket"))
let socket_path = Path::new(SOCKET_FILE_NAME);
// TODO: move listener into Daemon struct?
let listener = listener::Listener::new(socket_path)
// TODO
.unwrap();
// TODO: set up socket path, make it settable by the user
Expand Down Expand Up @@ -55,10 +60,11 @@ pub fn main() -> OpResult {
// handle.join().unwrap();
}

struct Daemon {
// TODO: move from ops to internals
pub struct Daemon {
// TODO: PathBuf is a nix file
pub handlers: HashMap<PathBuf, std::thread::JoinHandle<()>>,
pub build_events_tx: mpsc::Sender<build_loop::Event>,
handlers: HashMap<PathBuf, std::thread::JoinHandle<()>>,
build_events_tx: mpsc::Sender<build_loop::Event>,
}

impl Daemon {
Expand Down Expand Up @@ -98,8 +104,9 @@ impl Daemon {
}

/// Handle the ping
// TODO: make private again
// the ReadWriter here has to be the inverse of the `Client.ping()`, which is `ReadWriter<!, Ping>`
fn ping(rw: ReadWriter<Ping, NoMessage>, build_chan: mpsc::Sender<StartBuild>) {
pub fn ping(rw: ReadWriter<Ping, NoMessage>, build_chan: mpsc::Sender<StartBuild>) {
// TODO: read timeout
let ping: Result<Ping, ReadError> = rw.read(None);
match ping {
Expand Down

0 comments on commit f95f17c

Please sign in to comment.