feat: iroh-services relay preset_builder#81
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh-services/pr/81/docs/iroh_services/ Last updated: 2026-05-20T10:14:08Z |
| // pro & enterprise projects have access to custom relays, which are set | ||
| // with the `relays` method on the builder. | ||
| // You'll need to replace these strings with the relay urls for your project. | ||
| let _preset = iroh_services::preset() |
There was a problem hiding this comment.
Is this example actually runnable? It seems like all of the other examples in this repository can be run by setting the API SECRET in env without modifying the code.
I'd prefer to keep it that way, and instead put this information in the documentation (https://docs.iroh.computer) and link to it from the README of this repository as well as the relays page on iroh services.
There was a problem hiding this comment.
yep it's runnable! Or at least, it is on my dev branch & should be generally. I added a note about setting the IROH_SERVICES_API_SECRET in the example description in c124d31
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// How long tokens are valid for by default | ||
| pub(crate) const DEFAULT_CAP_EXPIRY: Duration = Duration::from_secs(60 * 60 * 24 * 30); // 1 month |
There was a problem hiding this comment.
maybe use Duration::from_days?
There was a problem hiding this comment.
no such method I'm afraid, but I can bump up to Duration::from_hours
| api_secret::{API_SECRET_ENV_VAR_NAME, ApiSecret}, | ||
| client::{Client, ClientBuilder}, | ||
| net_diagnostics::{DiagnosticsReport, checks::run_diagnostics}, | ||
| preset::{IrohServicesPreset, PresetBuilder, preset}, |
There was a problem hiding this comment.
I know we have the bad precedent, but having a pub mod and pub use is really confusing
There was a problem hiding this comment.
not sure if this fully addresses it, but I've made preset private, and just exported the main types. Is that better?
| preset() | ||
| } | ||
|
|
||
| /// Returns the [`ApiSecret`] stashed on this preset, if one was set. |
There was a problem hiding this comment.
stashed is very odd wording
| pub fn client_builder(&self, endpoint: &Endpoint) -> ClientBuilder { | ||
| ClientBuilder::new(endpoint) | ||
| .api_secret(self.api_secret.clone()) | ||
| .unwrap() |
There was a problem hiding this comment.
If you dig into the builder, the api_secret method on the builder has been factored to the point that it can no longer fail. I'll add a comment as such at a bare minimum, but can also either make this bubble up a Result, or we can break the API one last time, your call
| self | ||
| } | ||
|
|
||
| pub fn relays<I, S>(mut self, relays: I) -> Result<Self> |
There was a problem hiding this comment.
added an example to help make the generic argument more understandable
Description
We should wait to merge this until upstream work is completed in iroh services.
Breaking Changes
Notes & open questions
Change checklist