Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
feat: Introduce a streaming way to encode BodyChunkIpld. Fixes #498
Browse files Browse the repository at this point in the history
* Introduce streaming `BodyChunkIpld::encode` and
  `BodyChunkIpld::decode` methods.
* Streaming mechanisms store data in memory until a threshold is hit,
  which then stores to disk.
* Mark non-streaming functions `BodyChunkIpld::load_all_bytes` and
  `BodyChunkIpld::store_bytes` as deprecated.
* Remove `BodyChunkDecoder` (now implemented as `BodyChunkIpld::decode`.
* Promote `bytes` to a workspace dependency.
  • Loading branch information
jsantell committed Aug 10, 2023
1 parent d33492a commit 84d7ea2
Show file tree
Hide file tree
Showing 14 changed files with 376 additions and 52 deletions.
7 changes: 7 additions & 0 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 @@ -19,6 +19,7 @@ resolver = "2"
[workspace.dependencies]
anyhow = { version = "1" }
axum = { version = "^0.6.18" }
bytes = { version = "^1" }
cid = { version = "0.10" }
directories = { version = "5" }
fastcdc = { version = "3.1" }
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere-cli/src/native/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Content {
};

let file_bytes = fs::read(path).await?;
let body_cid = BodyChunkIpld::store_bytes(&file_bytes, store).await?;
let body_cid = BodyChunkIpld::encode(file_bytes.as_ref(), store).await?;

content.matched.insert(
slug,
Expand Down
4 changes: 3 additions & 1 deletion rust/noosphere-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ sentry = ["dep:sentry-tracing"]
helpers = []

[dependencies]
bytes = { workspace = true }
tempfile = { workspace = true }
tracing = { workspace = true }
cid = { workspace = true }
url = { workspace = true }
Expand All @@ -35,7 +37,7 @@ async-stream = "~0.3"
async-once-cell = "~0.4"
anyhow = "^1"
thiserror = { workspace = true }
fastcdc = { workspace = true }
fastcdc = { workspace = true, features = ["tokio"] }
futures = "~0.3"
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
Loading

0 comments on commit 84d7ea2

Please sign in to comment.