Skip to content

refactor: Change concurrency approach #100

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
90c23be
Add entity-manager dep
rklaehn Jul 8, 2025
90db719
Remove unused dependencies
rklaehn Jul 8, 2025
24c7f2c
Merge branch 'lose-futures-buffered-dep' into entity-manager
rklaehn Jul 8, 2025
126d834
Merge branch 'main' into entity-manager
rklaehn Jul 8, 2025
264ed84
Add import
rklaehn Jul 8, 2025
a859674
Add helpers for set and update
rklaehn Jul 8, 2025
baf4d54
Make bipolar clippy happy again
rklaehn Jul 8, 2025
66f8540
Move message sending into meta
rklaehn Jul 8, 2025
9193b08
Merge branch 'remove-db-public-send' into entity-manager
rklaehn Jul 8, 2025
8cae7cd
WIP
rklaehn Jul 8, 2025
161a70b
Replace slots with EntityHandler
rklaehn Jul 8, 2025
169261a
Get rid of the weak reference
rklaehn Jul 8, 2025
6fe2e07
Inline entity manager and streamline the dispatcher code a bit
rklaehn Jul 9, 2025
fd9faab
revert a few changes to minimize the diff
rklaehn Jul 9, 2025
8ac1b78
codespell
rklaehn Jul 9, 2025
011746d
remove debug code
rklaehn Jul 9, 2025
def9abc
more comments
rklaehn Jul 9, 2025
47cab9c
Add property based tests for the entity manager
rklaehn Jul 10, 2025
00c54f3
Add a property based test that tests basic functionality of the entit…
rklaehn Jul 10, 2025
664beb8
clippy
rklaehn Jul 10, 2025
7b1b71b
Merge branch 'main' into entity-manager
rklaehn Jul 10, 2025
e584ad1
fmt
rklaehn Jul 10, 2025
4412be9
Add tests for the busy and dead cases which are hard to trigger witho…
rklaehn Jul 10, 2025
c26e555
clippy again
rklaehn Jul 10, 2025
8004115
Merge branch 'main' into entity-manager
rklaehn Jul 11, 2025
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
24 changes: 22 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ testresult = "0.4.1"
tracing-subscriber = { version = "0.3.19", features = ["fmt"] }
tracing-test = "0.2.5"
walkdir = "2.5.0"
atomic_refcell = "0.1.13"

[features]
hide-proto-docs = []
Expand Down
24 changes: 12 additions & 12 deletions src/api/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Blobs {
.await
}

pub fn add_slice(&self, data: impl AsRef<[u8]>) -> AddProgress {
pub fn add_slice(&self, data: impl AsRef<[u8]>) -> AddProgress<'_> {
let options = ImportBytesRequest {
data: Bytes::copy_from_slice(data.as_ref()),
format: crate::BlobFormat::Raw,
Expand All @@ -136,7 +136,7 @@ impl Blobs {
self.add_bytes_impl(options)
}

pub fn add_bytes(&self, data: impl Into<bytes::Bytes>) -> AddProgress {
pub fn add_bytes(&self, data: impl Into<bytes::Bytes>) -> AddProgress<'_> {
let options = ImportBytesRequest {
data: data.into(),
format: crate::BlobFormat::Raw,
Expand All @@ -145,7 +145,7 @@ impl Blobs {
self.add_bytes_impl(options)
}

pub fn add_bytes_with_opts(&self, options: impl Into<AddBytesOptions>) -> AddProgress {
pub fn add_bytes_with_opts(&self, options: impl Into<AddBytesOptions>) -> AddProgress<'_> {
let options = options.into();
let request = ImportBytesRequest {
data: options.data,
Expand All @@ -155,7 +155,7 @@ impl Blobs {
self.add_bytes_impl(request)
}

fn add_bytes_impl(&self, options: ImportBytesRequest) -> AddProgress {
fn add_bytes_impl(&self, options: ImportBytesRequest) -> AddProgress<'_> {
trace!("{options:?}");
let this = self.clone();
let stream = Gen::new(|co| async move {
Expand All @@ -180,7 +180,7 @@ impl Blobs {
AddProgress::new(self, stream)
}

pub fn add_path_with_opts(&self, options: impl Into<AddPathOptions>) -> AddProgress {
pub fn add_path_with_opts(&self, options: impl Into<AddPathOptions>) -> AddProgress<'_> {
let options = options.into();
self.add_path_with_opts_impl(ImportPathRequest {
path: options.path,
Expand All @@ -190,7 +190,7 @@ impl Blobs {
})
}

fn add_path_with_opts_impl(&self, options: ImportPathRequest) -> AddProgress {
fn add_path_with_opts_impl(&self, options: ImportPathRequest) -> AddProgress<'_> {
trace!("{:?}", options);
let client = self.client.clone();
let stream = Gen::new(|co| async move {
Expand All @@ -215,7 +215,7 @@ impl Blobs {
AddProgress::new(self, stream)
}

pub fn add_path(&self, path: impl AsRef<Path>) -> AddProgress {
pub fn add_path(&self, path: impl AsRef<Path>) -> AddProgress<'_> {
self.add_path_with_opts(AddPathOptions {
path: path.as_ref().to_owned(),
mode: ImportMode::Copy,
Expand All @@ -226,7 +226,7 @@ impl Blobs {
pub async fn add_stream(
&self,
data: impl Stream<Item = io::Result<Bytes>> + Send + Sync + 'static,
) -> AddProgress {
) -> AddProgress<'_> {
let inner = ImportByteStreamRequest {
format: crate::BlobFormat::Raw,
scope: Scope::default(),
Expand Down Expand Up @@ -521,7 +521,7 @@ pub struct Batch<'a> {
}

impl<'a> Batch<'a> {
pub fn add_bytes(&self, data: impl Into<Bytes>) -> BatchAddProgress {
pub fn add_bytes(&self, data: impl Into<Bytes>) -> BatchAddProgress<'_> {
let options = ImportBytesRequest {
data: data.into(),
format: crate::BlobFormat::Raw,
Expand All @@ -530,7 +530,7 @@ impl<'a> Batch<'a> {
BatchAddProgress(self.blobs.add_bytes_impl(options))
}

pub fn add_bytes_with_opts(&self, options: impl Into<AddBytesOptions>) -> BatchAddProgress {
pub fn add_bytes_with_opts(&self, options: impl Into<AddBytesOptions>) -> BatchAddProgress<'_> {
let options = options.into();
BatchAddProgress(self.blobs.add_bytes_impl(ImportBytesRequest {
data: options.data,
Expand All @@ -539,7 +539,7 @@ impl<'a> Batch<'a> {
}))
}

pub fn add_slice(&self, data: impl AsRef<[u8]>) -> BatchAddProgress {
pub fn add_slice(&self, data: impl AsRef<[u8]>) -> BatchAddProgress<'_> {
let options = ImportBytesRequest {
data: Bytes::copy_from_slice(data.as_ref()),
format: crate::BlobFormat::Raw,
Expand All @@ -548,7 +548,7 @@ impl<'a> Batch<'a> {
BatchAddProgress(self.blobs.add_bytes_impl(options))
}

pub fn add_path_with_opts(&self, options: impl Into<AddPathOptions>) -> BatchAddProgress {
pub fn add_path_with_opts(&self, options: impl Into<AddPathOptions>) -> BatchAddProgress<'_> {
let options = options.into();
BatchAddProgress(self.blobs.add_path_with_opts_impl(ImportPathRequest {
path: options.path,
Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl From<&[u8; 32]> for Hash {

impl PartialOrd for Hash {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.0.as_bytes().cmp(other.0.as_bytes()))
Some(self.cmp(other))
}
}

Expand Down
1 change: 1 addition & 0 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use iroh_metrics::{Counter, MetricsGroup};

/// Enum of metrics for the module
#[allow(missing_docs)]
#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this dead code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to rethink what metrics to collect, many of those aren't even relevant anymore.

#[derive(Debug, Default, MetricsGroup)]
#[metrics(name = "iroh-blobs")]
pub struct Metrics {
Expand Down
Loading
Loading