Skip to content

Instantly share code, notes, and snippets.

@maxux
Created April 21, 2020 16:23
Show Gist options
  • Save maxux/9d79b913f5012c8eb7f029e9ddd0498b to your computer and use it in GitHub Desktop.
Save maxux/9d79b913f5012c8eb7f029e9ddd0498b to your computer and use it in GitHub Desktop.
use redis::Commands;
use std::{
fs::File,
io::{self, BufRead, BufReader},
os::unix::io::FromRawFd,
};
fn main() -> io::Result<()> {
let client = redis::Client::open("redis://10.241.0.232").unwrap();
let r = client.get_connection().unwrap();
match r.publish("logdebug", "HELLO") {
Ok(()) => println!("redis: ok"),
Err(e) => println!("redis: {:?}", e),
}
let fout = unsafe { File::from_raw_fd(3) };
let ferr = unsafe { File::from_raw_fd(4) };
let ready = unsafe { File::from_raw_fd(5) };
drop(ready);
let reader = BufReader::new(fout);
for line in reader.lines() {
let linestr = line.unwrap();
match r.publish("logdebug", linestr) {
Ok(()) => println!("redis: ok"),
Err(e) => println!("redis: {:?}", e),
}
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment