Skip to content

feat: Enable RPC by default #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 14, 2025
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ futures-util = "0.3.30"
testdir = "0.9.1"

[features]
default = ["fs-store", "net_protocol"]
default = ["fs-store", "net_protocol", "rpc"]
downloader = ["dep:parking_lot", "tokio-util/time", "dep:hashlink"]
net_protocol = ["downloader", "dep:futures-util"]
fs-store = ["dep:reflink-copy", "redb", "dep:tempfile"]
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
//! The [downloader] module provides a component to download blobs from
//! multiple sources and store them in a store.
//!
//! # Feature flags
//!
//! - rpc: Enable the rpc server and client. Enabled by default.
//! - net_protocol: Enable the network protocol. Enabled by default.
//! - downloader: Enable the downloader. Enabled by default.
//! - fs-store: Enable the filesystem store. Enabled by default.
//!
//! - cli: Enable the cli. Disabled by default.
//! - example-iroh: dependencies for examples in this crate. Disabled by default.
//! - test: test utilities. Disabled by default.
//!
//! [BLAKE3]: https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf
//! [iroh]: https://docs.rs/iroh
#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
Expand Down
17 changes: 8 additions & 9 deletions src/rpc/client/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
use std::ops::{Bound, RangeBounds};

use anyhow::Result;
use futures_lite::{io, Stream, StreamExt};
use futures_lite::{Stream, StreamExt};
use quic_rpc::{client::BoxedConnector, Connector, RpcClient};
use serde::{Deserialize, Serialize};

use crate::{
rpc::proto::{
tags::{DeleteRequest, ListRequest, SetRequest, SyncMode},
tags::{DeleteRequest, ListRequest, RenameRequest, SetRequest, SyncMode},
RpcService,
},
BlobFormat, Hash, HashAndFormat, Tag,
Expand Down Expand Up @@ -235,13 +235,12 @@ where
///
/// If the tag does not exist, this will return an error.
pub async fn rename(&self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>) -> Result<()> {
let from = from.as_ref();
let to = to.as_ref();
let Some(old) = self.get(from.as_ref()).await? else {
return Err(io::Error::new(io::ErrorKind::NotFound, "Tag not found").into());
};
self.set(to.as_ref(), old.hash_and_format()).await?;
self.delete(from.as_ref()).await?;
self.rpc
.rpc(RenameRequest {
from: Tag::from(from.as_ref()),
to: Tag::from(to.as_ref()),
})
.await??;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ impl ActorState {
fn rename_tag(&mut self, tables: &mut Tables, from: Tag, to: Tag) -> ActorResult<()> {
let value = tables
.tags
.get(from)?
.remove(from)?
.ok_or_else(|| {
ActorError::Io(io::Error::new(io::ErrorKind::NotFound, "tag not found"))
})?
Expand Down
Loading