Skip to content

Commit 8e227c0

Browse files
authored
Merge 127a9fd into 73ca073
2 parents 73ca073 + 127a9fd commit 8e227c0

File tree

7 files changed

+17
-62
lines changed

7 files changed

+17
-62
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ self_cell = "1.1.0"
4242
genawaiter = { version = "0.99.1", features = ["futures03"] }
4343
iroh-base = "0.90"
4444
reflink-copy = "0.1.24"
45-
irpc = { version = "0.5.0", features = ["rpc", "quinn_endpoint_setup", "message_spans", "stream", "derive"], default-features = false }
45+
irpc = { version = "0.5.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
4646
iroh-metrics = { version = "0.35" }
4747

4848
[dev-dependencies]
@@ -69,4 +69,3 @@ default = ["hide-proto-docs"]
6969
iroh = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
7070
iroh-base = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
7171
irpc = { git = "https://github.com/n0-computer/irpc.git", branch = "main" }
72-
irpc-derive = { git = "https://github.com/n0-computer/irpc.git", branch = "main" }

src/api.rs

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
//!
1313
//! You can also [`connect`](Store::connect) to a remote store that is listening
1414
//! to rpc requests.
15-
use std::{io, net::SocketAddr, ops::Deref, sync::Arc};
15+
use std::{io, net::SocketAddr, ops::Deref};
1616

1717
use bao_tree::io::EncodeError;
1818
use iroh::Endpoint;
19-
use irpc::rpc::{listen, Handler};
19+
use irpc::rpc::{listen, RemoteService};
2020
use n0_snafu::SpanTrace;
2121
use nested_enum_utils::common_fields;
2222
use proto::{Request, ShutdownRequest, SyncDbRequest};
@@ -32,7 +32,7 @@ pub mod remote;
3232
pub mod tags;
3333
pub use crate::{store::util::Tag, util::temp_tag::TempTag};
3434

35-
pub(crate) type ApiClient = irpc::Client<proto::Command, proto::Request, proto::StoreService>;
35+
pub(crate) type ApiClient = irpc::Client<proto::Request>;
3636

3737
#[common_fields({
3838
backtrace: Option<Backtrace>,
@@ -281,42 +281,8 @@ impl Store {
281281

282282
/// Listen on a quinn endpoint for incoming rpc connections.
283283
pub async fn listen(self, endpoint: quinn::Endpoint) {
284-
let local = self.client.local().unwrap().clone();
285-
let handler: Handler<Request> = Arc::new(move |req, rx, tx| {
286-
let local = local.clone();
287-
Box::pin({
288-
match req {
289-
Request::SetTag(msg) => local.send((msg, tx)),
290-
Request::CreateTag(msg) => local.send((msg, tx)),
291-
Request::DeleteTags(msg) => local.send((msg, tx)),
292-
Request::RenameTag(msg) => local.send((msg, tx)),
293-
Request::ListTags(msg) => local.send((msg, tx)),
294-
295-
Request::ListTempTags(msg) => local.send((msg, tx)),
296-
Request::CreateTempTag(msg) => local.send((msg, tx)),
297-
298-
Request::BlobStatus(msg) => local.send((msg, tx)),
299-
300-
Request::ImportBytes(msg) => local.send((msg, tx)),
301-
Request::ImportByteStream(msg) => local.send((msg, tx, rx)),
302-
Request::ImportBao(msg) => local.send((msg, tx, rx)),
303-
Request::ImportPath(msg) => local.send((msg, tx)),
304-
Request::ListBlobs(msg) => local.send((msg, tx)),
305-
Request::DeleteBlobs(msg) => local.send((msg, tx)),
306-
Request::Batch(msg) => local.send((msg, tx, rx)),
307-
308-
Request::ExportBao(msg) => local.send((msg, tx)),
309-
Request::ExportRanges(msg) => local.send((msg, tx)),
310-
Request::ExportPath(msg) => local.send((msg, tx)),
311-
312-
Request::Observe(msg) => local.send((msg, tx)),
313-
314-
Request::ClearProtected(msg) => local.send((msg, tx)),
315-
Request::SyncDb(msg) => local.send((msg, tx)),
316-
Request::Shutdown(msg) => local.send((msg, tx)),
317-
}
318-
})
319-
});
284+
let local = self.client.as_local().unwrap().clone();
285+
let handler = Request::remote_handler(local);
320286
listen::<Request>(endpoint, handler).await
321287
}
322288

src/api/downloader.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@ use crate::{
2929

3030
#[derive(Debug, Clone)]
3131
pub struct Downloader {
32-
client: irpc::Client<SwarmMsg, SwarmProtocol, DownloaderService>,
32+
client: irpc::Client<SwarmProtocol>,
3333
}
3434

35-
#[derive(Debug, Clone)]
36-
pub struct DownloaderService;
37-
38-
impl irpc::Service for DownloaderService {}
39-
40-
#[rpc_requests(DownloaderService, message = SwarmMsg, alias = "Msg")]
35+
#[rpc_requests(message = SwarmMsg, alias = "Msg")]
4136
#[derive(Debug, Serialize, Deserialize)]
4237
enum SwarmProtocol {
4338
#[rpc(tx = mpsc::Sender<DownloadProgessItem>)]

src/api/proto.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ impl HashSpecific for CreateTagMsg {
8686
}
8787
}
8888

89-
#[derive(Debug, Clone)]
90-
pub struct StoreService;
91-
impl irpc::Service for StoreService {}
92-
93-
#[rpc_requests(StoreService, message = Command, alias = "Msg")]
89+
#[rpc_requests(message = Command, alias = "Msg")]
9490
#[derive(Debug, Serialize, Deserialize)]
9591
pub enum Request {
9692
#[rpc(tx = mpsc::Sender<super::Result<Hash>>)]

src/store/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ impl AsRef<Store> for FsStore {
12591259

12601260
impl FsStore {
12611261
fn new(
1262-
sender: irpc::LocalSender<proto::Command, proto::StoreService>,
1262+
sender: irpc::LocalSender<proto::Request>,
12631263
db: tokio::sync::mpsc::Sender<InternalCommand>,
12641264
) -> Self {
12651265
Self {

src/store/fs/import.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ use crate::{
3939
blobs::{AddProgressItem, ImportMode},
4040
proto::{
4141
HashSpecific, ImportByteStreamMsg, ImportByteStreamRequest, ImportByteStreamUpdate,
42-
ImportBytesMsg, ImportBytesRequest, ImportPathMsg, ImportPathRequest, Scope,
43-
StoreService,
42+
ImportBytesMsg, ImportBytesRequest, ImportPathMsg, ImportPathRequest, Request, Scope,
4443
},
4544
},
4645
store::{
@@ -136,12 +135,12 @@ impl std::fmt::Debug for ImportEntry {
136135
}
137136
}
138137

139-
impl Channels<StoreService> for ImportEntry {
138+
impl Channels<Request> for ImportEntry {
140139
type Tx = mpsc::Sender<AddProgressItem>;
141140
type Rx = NoReceiver;
142141
}
143142

144-
pub type ImportEntryMsg = WithChannels<ImportEntry, StoreService>;
143+
pub type ImportEntryMsg = WithChannels<ImportEntry, Request>;
145144

146145
impl HashSpecific for ImportEntryMsg {
147146
fn hash(&self) -> Hash {

0 commit comments

Comments
 (0)