Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions examples/quickstart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ use iroh_services::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();

let endpoint = Endpoint::bind(presets::N0).await?;

// Wait for the endpoint to be online
endpoint.online().await;

Comment on lines +10 to +12
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint.online().await can block indefinitely if the endpoint never establishes a relay connection (e.g., offline network). Elsewhere (e.g. src/net_diagnostics.rs) this wait is wrapped in tokio::time::timeout with a warning; consider doing the same here (or otherwise bounding the wait) so the quickstart doesn’t hang without feedback.

Copilot uses AI. Check for mistakes.
// needs IROH_SERVICES_API_SECRET set to an environment variable
// client will now push endpoint metrics to iroh-services
let client = Client::builder(&endpoint)
.api_secret_from_env()?
.name("quickstart-example")?
.build()
.await?;

// we can also ping the service just to confirm everything is working
client.ping().await?;

// keep the endpoint running so it continues pushing metrics.
// ctrl+c to exit.
println!("endpoint running. ctrl+c to exit.");
tokio::signal::ctrl_c().await?;
endpoint.close().await;

Ok(())
}
Loading