-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standard input/output support 1: stream RRD data from stdin (#4511)
Add a `stdin` source to the viewer so it can stream data in from standard input. We make `stdin` an explicit input (`rerun -`) like in the good old days, to avoid shady behavior in non-TTY and other esoteric environment (crazy WSL setups, etc). Trust me, it gets quite insane... Checks: - [x] `rerun` works - [x] `rerun -` blocks - [x] `rerun - < data.rrd` works - [x] `cat data.rrd | rerun -` works - [x] `rerun < data.rrd` works but does nothing - [x] `cat data.rrd | rerun` works but does nothing - [x] no-TTY & other esoteric environments don't go completely off the rails --- Part of a small PR series to add stdio streaming support to our Viewer and SDKs: - #4511 - #4512 - #4513 - #4514
- Loading branch information
Showing
11 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use re_log_types::LogMsg; | ||
use re_smart_channel::Sender; | ||
|
||
/// Asynchronously loads RRD data streaming in from standard input. | ||
/// | ||
/// This fails synchronously iff the standard input stream could not be opened, otherwise errors | ||
/// are handlded asynchronously (as in: they're logged). | ||
pub fn load_stdin(tx: Sender<LogMsg>) -> anyhow::Result<()> { | ||
let version_policy = re_log_encoding::decoder::VersionPolicy::Warn; | ||
|
||
let decoder = re_log_encoding::decoder::Decoder::new(version_policy, std::io::stdin())?; | ||
|
||
rayon::spawn(move || { | ||
re_tracing::profile_scope!("stdin"); | ||
|
||
for msg in decoder { | ||
let msg = match msg { | ||
Ok(msg) => msg, | ||
Err(err) => { | ||
re_log::warn_once!("Failed to decode message in stdin: {err}"); | ||
continue; | ||
} | ||
}; | ||
if tx.send(msg).is_err() { | ||
break; // The other end has decided to hang up, not our problem. | ||
} | ||
} | ||
|
||
tx.quit(None).ok(); // The other end has decided to hang up, not our problem. | ||
}); | ||
|
||
Ok(()) | ||
} |
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
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
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
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
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
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
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