Created
April 21, 2020 16:23
-
-
Save maxux/9d79b913f5012c8eb7f029e9ddd0498b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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