Skip to content

docs: use preset.client_builder in examples - #91

Merged
okdistribute merged 1 commit into
mainfrom
rae/docs-preset-client-builder
Aug 11, 2026
Merged

docs: use preset.client_builder in examples#91
okdistribute merged 1 commit into
mainfrom
rae/docs-preset-client-builder

Conversation

@okdistribute

Copy link
Copy Markdown
Contributor

Docs counterpart to n0-computer/iroh-services#100.

The preset already carries the API key — and the iroh-services endpoint address inside it — but these snippets reached for Client::builder, which starts blank. Readers either passed the key twice or hit "Missing remote endpoint to dial" when they gave it only to the preset.

Now every snippet builds a preset, binds with preset.clone(), and gets its client from preset.client_builder(&endpoint):

  • snippets/iroh-services-setup.mdx (Rust block only; the FFI bindings take the key directly)
  • iroh-services/access.mdx
  • iroh-services/metrics/custom.mdx
  • iroh-services/net-diagnostics/quickstart.mdx

custom.mdx also documented client.metric("document_written", 1), which is not a real method. Replaced with the actual API: a MetricsGroup-deriving struct registered through register_metrics_group.

Every Rust snippet in this PR was compile-checked against iroh-services main as a throwaway example.

Left alone: connect-two-endpoints.mdx binds a plain presets::N0 endpoint and attaches the services client only when the env var is set. Client::builder(&endpoint).api_secret_from_env() sets the remote itself, so that page is correct as written.

🤖 Generated with Claude Code

https://claude.ai/code/session_013ebw1QzA5dpk9iVDZ29zkz

The preset already carries the API key (and the iroh-services endpoint
address inside it), but the examples reached for `Client::builder`, which
starts blank — so readers passed the key twice, or hit "Missing remote
endpoint to dial" if they only gave it to the preset. Mirrors
n0-computer/iroh-services#100.

- setup snippet, access, custom metrics, net diagnostics: build a preset,
  bind with `preset.clone()`, then `preset.client_builder(&endpoint)`
- custom metrics also called `client.metric(name, value)`, which does not
  exist. Replaced with the real API: a `MetricsGroup` struct registered
  via `register_metrics_group`

Every snippet here was compile-checked against iroh-services main.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ebw1QzA5dpk9iVDZ29zkz
@okdistribute
okdistribute merged commit 481556e into main Aug 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant