Skip to content
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

feat!: add block streaming interface #44

Merged
merged 3 commits into from
May 14, 2024

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented May 8, 2024

This PR adds a streamBlock(cid, [options]) method to Dagula that returns a ReadableStream of block bytes. You can optionally pass a byte range to extract a subset of bytes.

Also statBlock(cid, [options]) that retrieves block info i.e. total size in bytes.

The idea is to allow dagula to serve byte ranges from big blocks without having to load the whole thing into memory.

BREAKING CHANGE: The Blockstore interface now includes a stream method that returns a ReadableStream and a stat method that returns info (byte size).

The format for the entityBytes option of getPath has changed. It is now an array of 1 or 2 numbers. See Range type for more details.

refs storacha/freeway#100 (comment)

walkUnixfsPath (path: UnknownLink|string, options?: AbortOptions): AsyncIterableIterator<UnixFSEntry>
}

export declare class Dagula implements IDagula {
export declare class Dagula implements BlockService, DagService, UnixfsService {
Copy link
Member Author

@alanshaw alanshaw May 13, 2024

Choose a reason for hiding this comment

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

Note: I'm planning on separating this into multiple classes that implement the respective interfaces. However it's going to take a bit of time because the unixfs specific stuff is all mixed up with the generic DAG traversal stuff.

WIP: #45

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

LGTM! ✨

@alanshaw alanshaw merged commit 2236fe4 into main May 14, 2024
3 checks passed
@alanshaw alanshaw deleted the feat/add-block-streaming-interface branch May 14, 2024 16:19
alanshaw pushed a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[8.0.0](v7.3.0...v8.0.0)
(2024-05-14)


### ⚠ BREAKING CHANGES

* The `Blockstore` interface now includes a `stream` method that returns
a `ReadableStream` and a `stat` method that returns info (byte size).

### Features

* add block streaming interface
([#44](#44))
([2236fe4](2236fe4))


### Bug Fixes

* remove only test
([#42](#42))
([ca858fb](ca858fb))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
alanshaw pushed a commit to storacha/gateway-lib that referenced this pull request May 14, 2024
Supports byte ranges for raw block requests - including multipart.

depends on storacha/dagula#44

refs storacha/freeway#100 (comment)

BREAKING CHANGE: dependencies for handlers have changed, splitting out block, DAG and unixfs services. These are all satisfied by the `Dagula` class for the time being.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants