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, making its metrics easier to identify.
Often a database user id, machine name, or other stable identifier from your application. A name must be 2 to 128 bytes of UTF-8; uniqueness is not enforced, so different endpoints may share a name.
Validation errors are returned here. The name is sent to the server after
the client authenticates; a failure to send it at that point is logged at
warn level rather than returned; use Client::set_name to set it later
with explicit error handling.
Sourcepub fn group(self, group: impl Into<String>) -> Result<Self>
pub fn group(self, group: impl Into<String>) -> Result<Self>
Attach the endpoint to a single named group when the client first authenticates.
A group name must be 2 to 128 bytes of UTF-8. Validation errors are returned
here. The group is sent to the server after the client authenticates; a
failure to send it at that point is logged at warn level rather than
returned; use Client::set_group to set it later with explicit error
handling.
Sourcepub fn attributes<I, K, V>(self, attrs: I) -> Result<Self>
pub fn attributes<I, K, V>(self, attrs: I) -> Result<Self>
Attach arbitrary key-value attributes to the endpoint when the client
first authenticates. Accepts any iterable of (key, value) pairs:
let _ = Client::builder(endpoint).attributes([("env", "prod"), ("region", "us-west")])?;Each key must be 2 to 128 bytes of UTF-8; values may be empty and are capped
at 128 bytes; at most 128 entries are allowed. Validation errors are
returned here. The attributes are sent to the server after the client
authenticates; a failure to send them at that point is logged at warn
level rather than returned; use Client::set_attributes to set them
later with explicit error handling.
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.
The file must contain an unencrypted PEM-encoded OpenSSH ed25519 private key.
Sourcepub fn ssh_key(self, pem: &str) -> Result<Self>
pub fn ssh_key(self, pem: &str) -> Result<Self>
Creates the capability from the provided PEM-encoded OpenSSH ed25519 private key.
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl !UnwindSafe for ClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more