pub struct ClientBuilder { /* private fields */ }Expand description
ClientBuilder provides configures and builds a iroh-services client, typically
created with Client::builder
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
pub fn new(endpoint: &Endpoint) -> Self
Sourcepub fn register_metrics_group(
self,
metrics_group: Arc<dyn MetricsGroup>,
) -> Self
pub fn register_metrics_group( self, metrics_group: Arc<dyn MetricsGroup>, ) -> Self
Register a metrics group to forward to iroh-services
The default registered metrics uses only the endpoint
Sourcepub fn metrics_interval(self, interval: Duration) -> Self
pub fn metrics_interval(self, interval: Duration) -> Self
Set the metrics collection interval
Defaults to enabled, every 60 seconds.
Sourcepub fn disable_metrics_interval(self) -> Self
pub fn disable_metrics_interval(self) -> Self
Disable metrics collection.
Sourcepub fn name(self, name: impl Into<String>) -> Result<Self>
pub fn name(self, name: impl Into<String>) -> Result<Self>
Set an optional human-readable name for the endpoint the client is constructed with, making metrics from this endpoint easier to identify. This is often used for associating with other services in your app, like a database user id, machine name, permanent username, etc.
When this builder method is called, the provided name is sent after the
client initially authenticates the endpoint server-side.
Errors will not interrupt client construction, instead producing a
warn-level log. For explicit error handling, use Client::set_name.
names can be any UTF-8 string, with a min length of 2 bytes, and maximum length of 128 bytes. name uniqueness is not enforced server-side, which means using the same name for different endpoints will not produce an error
Sourcepub fn api_secret_from_env(self) -> Result<Self>
pub fn api_secret_from_env(self) -> Result<Self>
Check IROH_SERVICES_API_SECRET environment variable for a valid API secret
Sourcepub fn api_secret_from_str(self, secret_key: &str) -> Result<Self>
pub fn api_secret_from_str(self, secret_key: &str) -> Result<Self>
set client API secret from an encoded string
Sourcepub fn api_secret(self, ticket: ApiSecret) -> Result<Self>
pub fn api_secret(self, ticket: ApiSecret) -> Result<Self>
Use a shared secret & remote iroh-services endpoint ID contained within a ticket to construct a iroh-services client. The resulting client will have “Client” capabilities.
API secrets include remote details within them, and will set both the remote and rcan values on the builder
Sourcepub async fn ssh_key_from_file<P: AsRef<Path>>(self, path: P) -> Result<Self>
pub async fn ssh_key_from_file<P: AsRef<Path>>(self, path: P) -> Result<Self>
Loads the private ssh key from the given path, and creates the needed capability.
Sourcepub fn ssh_key(self, key: &PrivateKey) -> Result<Self>
pub fn ssh_key(self, key: &PrivateKey) -> Result<Self>
Creates the capability from the provided private ssh key.
Sourcepub fn remote(self, remote: impl Into<EndpointAddr>) -> Self
pub fn remote(self, remote: impl Into<EndpointAddr>) -> Self
Sets the remote to dial, must be provided either directly by calling this method, or through calling the api_secret builder methods.