Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
507 changes: 183 additions & 324 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tokio = { workspace = true, features = ["sync", "macros"] }
# for PollSender (which for some reason is not available in the main tokio api)
tokio-util = { version = "0.7.14", default-features = false }
# errors
thiserror = "2.0.12"
n0-error = { workspace = true }

# used in the endpoint handler code when using rpc
tracing = { workspace = true, optional = true }
Expand All @@ -37,8 +37,6 @@ smallvec = { version = "1.14.0", features = ["write"], optional = true }
rustls = { version = "0.23.5", default-features = false, features = ["std"], optional = true }
# used in the test utils to generate quinn endpoints
rcgen = { version = "0.14.5", optional = true }
# used in the test utils to generate quinn endpoints
anyhow = { workspace = true, optional = true }
# used in the benches
futures-buffered ={ version = "0.2.9", optional = true }
# for AbortOnDropHandle
Expand All @@ -61,12 +59,14 @@ thousands = "0.2.0"
# macro tests
trybuild = "1.0.104"
testresult = "0.4.1"
# used in examples
anyhow = { workspace = true }

[features]
# enable the remote transport
rpc = ["dep:quinn", "dep:postcard", "dep:anyhow", "dep:smallvec", "dep:tracing", "tokio/io-util"]
rpc = ["dep:quinn", "dep:postcard", "dep:smallvec", "dep:tracing", "tokio/io-util"]
# add test utilities
quinn_endpoint_setup = ["rpc", "dep:rustls", "dep:rcgen", "dep:anyhow", "dep:futures-buffered", "quinn/rustls-ring"]
quinn_endpoint_setup = ["rpc", "dep:rustls", "dep:rcgen", "dep:futures-buffered", "quinn/rustls-ring"]
# pick up parent span when creating channel messages
spans = ["dep:tracing"]
stream = ["dep:futures-util"]
Expand Down Expand Up @@ -101,14 +101,15 @@ rustdoc-args = ["--cfg", "quicrpc_docsrs"]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(quicrpc_docsrs)"] }

[workspace.dependencies]
anyhow = { version = "1.0.98" }
anyhow = { version = "1" }
tokio = { version = "1.44", default-features = false }
postcard = { version = "1.1.1", default-features = false }
serde = { version = "1", default-features = false, features = ["derive"] }
tracing = { version = "0.1.41", default-features = false }
n0-future = { version = "0.3", default-features = false }
n0-error = { version = "0.1.0" }
tracing-subscriber = { version = "0.3.20" }
iroh = { version = "0.94" }
iroh-base = { version = "0.94" }
iroh = { version = "0.95" }
iroh-base = { version = "0.95" }
quinn = { package = "iroh-quinn", version = "0.14.0", default-features = false }
futures-util = { version = "0.3", features = ["sink"] }
3 changes: 2 additions & 1 deletion irpc-iroh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ description = "Iroh transport for irpc"
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = { workspace = true }
iroh = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
tracing = { workspace = true }
serde = { workspace = true }
postcard = { workspace = true, features = ["alloc", "use-std"] }
n0-error = { workspace = true }
n0-future = { workspace = true }
irpc = { version = "0.10.0", path = ".." }
iroh-base.workspace = true
Expand All @@ -34,3 +34,4 @@ clap = { version = "4.5.41", features = ["derive"] }
futures-util.workspace = true
hex = "0.4.3"
rand = "0.9.2"
anyhow = { workspace = true }
23 changes: 6 additions & 17 deletions irpc-iroh/examples/0rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ mod cli {

mod ping {
use anyhow::{Context, Result};
use futures_util::FutureExt;
use iroh::Endpoint;
use irpc::{channel::oneshot, rpc::RemoteService, rpc_requests, Client, WithChannels};
use irpc_iroh::{Iroh0RttProtocol, IrohProtocol, IrohRemoteConnection};
use n0_future::future;
use irpc_iroh::{
Iroh0RttProtocol, IrohProtocol, IrohRemoteConnection, IrohZrttRemoteConnection,
};
use serde::{Deserialize, Serialize};
use tracing::info;

Expand All @@ -205,7 +205,6 @@ mod ping {

pub struct EchoApi {
inner: Client<EchoProtocol>,
zero_rtt_accepted: futures_util::future::Shared<future::Boxed<bool>>,
}

impl EchoApi {
Expand All @@ -216,9 +215,7 @@ mod ping {
}

pub async fn echo_0rtt(&self, data: Vec<u8>) -> irpc::Result<Vec<u8>> {
self.inner
.rpc_0rtt(Echo { data }, self.zero_rtt_accepted.clone())
.await
self.inner.rpc_0rtt(Echo { data }).await
}

pub fn expose_0rtt(self) -> Result<Iroh0RttProtocol<EchoProtocol>> {
Expand All @@ -245,10 +242,8 @@ mod ping {
.connect(addr, Self::ALPN)
.await
.context("failed to connect to remote service")?;
let fut: future::Boxed<bool> = Box::pin(async { true });
Ok(EchoApi {
inner: Client::boxed(IrohRemoteConnection::new(conn)),
zero_rtt_accepted: fut.shared(),
})
}

Expand All @@ -261,21 +256,17 @@ mod ping {
.await
.context("failed to connect to remote service")?;
match connecting.into_0rtt() {
Ok((conn, zero_rtt_accepted)) => {
Ok(conn) => {
info!("0-RTT possible from our side");
let fut: future::Boxed<bool> = Box::pin(zero_rtt_accepted);
Ok(EchoApi {
inner: Client::boxed(IrohRemoteConnection::new(conn)),
zero_rtt_accepted: fut.shared(),
inner: Client::boxed(IrohZrttRemoteConnection::new(conn)),
})
}
Err(connecting) => {
info!("0-RTT not possible from our side");
let fut: future::Boxed<bool> = Box::pin(async { true });
let conn = connecting.await?;
Ok(EchoApi {
inner: Client::boxed(IrohRemoteConnection::new(conn)),
zero_rtt_accepted: fut.shared(),
})
}
}
Expand All @@ -295,10 +286,8 @@ mod ping {
let (tx, rx) = tokio::sync::mpsc::channel(1);
let actor = Self { recv: rx };
n0_future::task::spawn(actor.run());
let fut: future::Boxed<bool> = Box::pin(async { true });
EchoApi {
inner: Client::local(tx),
zero_rtt_accepted: fut.shared(),
}
}

Expand Down
Loading
Loading