Repository navigation
Conversation
7680502 to
ab9d1ea
Compare
b14cdc0 to
23ddbbb
Compare
Run a configurable initializer before opening application streams on each new connection, including reconnects. Share connection setup between noq and iroh, with eager setup and cleanup on failure or cancellation. Update the auth example to reuse the same client after the server closes its connection. Cover concurrent callers, fixed connections, cancellation, and closed connections with a completed 0-RTT handshake.
OutgoingZeroRttConnection::connect turned every handshake error into RequestError::IrohConnect. A connection error now becomes ConnectionClosed or ConnectionFailed, as it does for open_bi on the same connection, so remote_code() returns the peer's close code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Keep the other examples and the irpc-opentelemetry tests on IrohLazyRemoteConnection, which still works. - Trim the auth example to the reconnect, and keep its variable names. - Test the anyhow conversion through the shared test helper instead of in a separate test. - Close an unfinished connection with one shared code and reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23ddbbb to
e39ae37
Compare
|
Two things about the new
/// The `on_connect` hook of the client returned an error.
#[cfg(feature = "rpc")]
#[error("on_connect hook failed")]
OnConnectFailed { source: n0_error::AnyError }, |
|
On second thought, /// Setting up a new connection failed, for example because the `on_connect` hook returned an error.
#[cfg(feature = "rpc")]
#[error("Connection setup failed")]
SetupFailed { source: n0_error::AnyError }, |
Description
Clients can now run setup requests, such as authentication, on each new
remote connection, before any application request uses it. This also happens
after a lazy client reconnects.
Before this PR, the lazy iroh and noq connections reconnected without informing
the user at all. If a server kept per-connection state (like
authed: boolinexamples/auth.rs), the client could not recover after a reconnect (#60).Client::noq_builder/Client::iroh_builderreturn aRemoteClientBuilder.RemoteClientBuilder::from_noq/from_irohwrapone existing connection.
Client::noq/Client::irohbehave as before.Clientbound to the new connection. All clones of theouter client wait until the hook returns
Ok. If setup fails or iscancelled, the connection is closed and not reused.
Client::connect()andRemoteConnection::connect()(with a defaultimpl), and new
RequestError::Initialization/ConnectUnsupportedvariants.
examples/auth.rsnow re-authenticates after the server drops theconnection.
Fixes #60
Replaces #61
Breaking Changes
None
Change checklist