-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): add support for Unix domain sockets (#388)
Add support for console connections that use Unix domain sockets rather than TCP. Closes #296. Co-authored-by: Eliza Weisman <eliza@buoyant.io>
- Loading branch information
Showing
9 changed files
with
208 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
//! Demonstrates serving the console API over a [Unix domain socket] (UDS) | ||
//! connection, rather than over TCP. | ||
//! | ||
//! Note that this example only works on Unix operating systems that | ||
//! support UDS, such as Linux, BSDs, and macOS. | ||
//! | ||
//! [Unix domain socket]: https://en.wikipedia.org/wiki/Unix_domain_socket | ||
#[cfg(unix)] | ||
use { | ||
std::time::Duration, | ||
tokio::{fs, task, time}, | ||
tracing::info, | ||
}; | ||
|
||
#[cfg(unix)] | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { | ||
let cwd = fs::canonicalize(".").await?; | ||
let addr = cwd.join("console-server"); | ||
console_subscriber::ConsoleLayer::builder() | ||
.server_addr(&*addr) | ||
.init(); | ||
info!( | ||
"listening for console connections at file://localhost{}", | ||
addr.display() | ||
); | ||
task::Builder::default() | ||
.name("sleepy") | ||
.spawn(async move { time::sleep(Duration::from_secs(90)).await }) | ||
.unwrap() | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[cfg(not(unix))] | ||
fn main() { | ||
panic!("only supported on Unix platforms") | ||
} |
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