-
-
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
Add support for console connections that use Unix domain sockets rather than TCP. Fix #296.
- Loading branch information
Showing
9 changed files
with
195 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,31 @@ | ||
//! 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 | ||
use std::time::Duration; | ||
use tokio::{fs, task, time}; | ||
use tracing::info; | ||
|
||
#[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(()) | ||
} |
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