generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 110
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(gateway): IPFSBackend metrics and HTTP range support #245
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,11 +54,13 @@ type ContentPathMetadata struct { | |
ContentType string // Only used for UnixFS requests | ||
} | ||
|
||
// GetRange describes a range request within a UnixFS file. From and To mostly follow HTTP Range Request semantics. | ||
// ByteRange describes a range request within a UnixFS file. From and To mostly follow [HTTP Byte Range] Request semantics. | ||
// From >= 0 and To = nil: Get the file (From, Length) | ||
// From >= 0 and To >= 0: Get the range (From, To) | ||
// From >= 0 and To <0: Get the range (From, Length - To) | ||
type GetRange struct { | ||
// | ||
// [HTTP Byte Range]: https://httpwg.org/specs/rfc9110.html#rfc.section.14.1.2 | ||
type ByteRange struct { | ||
From uint64 | ||
To *int64 | ||
} | ||
|
@@ -86,15 +88,24 @@ func NewGetResponseFromDirectoryListing(dagSize uint64, entries <-chan unixfs.Li | |
// There are also some existing error types that the gateway code knows how to handle (e.g. context.DeadlineExceeded | ||
// and various IPLD pathing related errors). | ||
type IPFSBackend interface { | ||
// Get returns a UnixFS file, UnixFS directory, or an IPLD block depending on what the path is that has been | ||
// requested. Directories' files.DirEntry objects do not need to contain content, but must contain Name, | ||
// Size, and Cid. | ||
Get(context.Context, ImmutablePath) (ContentPathMetadata, *GetResponse, error) | ||
|
||
// GetRange returns a full UnixFS file object. Ranges passed in are advisory for pre-fetching data, however | ||
// consumers of this function may require extra data beyond the passed ranges (e.g. the initial bit of the file | ||
// might be used for content type sniffing even if only the end of the file is requested). | ||
GetRange(context.Context, ImmutablePath, ...GetRange) (ContentPathMetadata, files.File, error) | ||
|
||
// Get returns a GetResponse with UnixFS file, directory or a block in IPLD | ||
// format e.g., (DAG-)CBOR/JSON. | ||
// | ||
// Returned Directories are preferably a minimum info required for enumeration: Name, Size, and Cid. | ||
// | ||
// Optional ranges follow [HTTP Byte Ranges] notation and can be used for | ||
// pre-fetching specific sections of a file or a block. | ||
// | ||
// Range notes: | ||
// - Generating response to a range request may require additional data | ||
// beyond the passed ranges (e.g. a single byte range from the middle of a | ||
// file will still need magic bytes from the very beginning for content | ||
// type sniffing). | ||
// - A range request for a directory currently holds no semantic meaning. | ||
// | ||
// [HTTP Byte Ranges]: https://httpwg.org/specs/rfc9110.html#rfc.section.14.1.2 | ||
Get(context.Context, ImmutablePath, ...ByteRange) (ContentPathMetadata, *GetResponse, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ removed |
||
|
||
// GetAll returns a UnixFS file or directory depending on what the path is that has been requested. Directories should | ||
// include all content recursively. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ there is no bitswap in bifrost-gateway, yet we got super confusing "Searching bitswap" message here ;)