pub struct Client { /* private fields */ }Expand description
Client is the main handle for interacting with iroh-services. It communicates with
iroh-services entirely through an iroh endpoint, and is configured through a builder.
Client requires either an Ssh Key or ApiSecret
use iroh::{Endpoint, endpoint::presets};
use iroh_services::Client;
async fn build_client() -> anyhow::Result<()> {
let endpoint = Endpoint::bind(presets::N0).await?;
// 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_str("MY_API_SECRET")?
.build()
.await;
Ok(())
}Implementations§
Source§impl Client
impl Client
pub fn builder(endpoint: &Endpoint) -> ClientBuilder
Sourcepub async fn push_metrics(&self) -> Result<(), Error>
pub async fn push_metrics(&self) -> Result<(), Error>
immediately send a single dump of metrics to iroh-services. It’s not necessary to call this function if you’re using a non-zero metrics interval, which will automatically propagate metrics on the set interval for you
Sourcepub async fn enable_alerts(&self) -> Result<LogMonitor, Error>
pub async fn enable_alerts(&self) -> Result<LogMonitor, Error>
Enable alert forwarding. Returns a LogMonitor tracing layer that
captures ERROR-level log events from the iroh crate and forwards
them to n0des. The caller must install the returned layer into their
tracing subscriber stack.
use tracing_subscriber::prelude::*;
let alert_layer = client.enable_alerts().await?;
tracing_subscriber::registry()
.with(alert_layer)
.with(tracing_subscriber::fmt::layer())
.init();Sourcepub async fn grant_capability(
&self,
remote_id: EndpointId,
caps: impl IntoIterator<Item = impl Into<Cap>>,
) -> Result<(), Error>
pub async fn grant_capability( &self, remote_id: EndpointId, caps: impl IntoIterator<Item = impl Into<Cap>>, ) -> Result<(), Error>
Grant capabilities to a remote endpoint. Creates a signed RCAN token and sends it to iroh-services for storage. The remote can then use this token when dialing back to authorize its requests.
Sourcepub async fn net_diagnostics(
&self,
send: bool,
) -> Result<DiagnosticsReport, Error>
pub async fn net_diagnostics( &self, send: bool, ) -> Result<DiagnosticsReport, Error>
run local network status diagnostics, optionally uploading the results