-
Notifications
You must be signed in to change notification settings - Fork 44
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
Implement go-ipld-prime readable and writable storage API (v2/storage) #363
Conversation
* New and Open(=resumable) functionality for ReadableWritable * Pull up blockstore options to carv2 package * Extracted shared blockstore code into internal/store
filecoin-project/lassie#69 for the initial use-case for this. See |
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.
I'm happy with this refactoring direction
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.
Cursory glance suggests this is a very good refactor. That said, I'm not going over with a fine tooth comb so probably make sur ethere is good test coverage given the size of the change.
there's better test coverage of this than the blockstore code |
will follow up a merge with a v2.7.0 release |
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
* Intended to replace github.com/ipfs/go-ipld-format#ErrNotFound * A new IsNotFound() that uses feature detection rather than type checking so it's compatible with old and new forms. Ref: ipld/go-car#363 Ref: #493
Primary goals
io
interfaces for each use-case, don't directly manageos.File
lifecycles (i.e. closing is not a concern of this API)WritableStorage
StreamingReadableStorage
that pulls outio.Reader
s fromGetStream()
calls to read directly from the underlying CAR data. This is what Implement a streaming read only IPLD native storage #349 was trying to do but on top of blockstore. I've pulled that commit in for posterity although I've not really used any of it.A use-case I have for this (will follow-up with a link to a Lassie PR) is to have read/write block storage and a streaming writable interface. I can do this nicely with this branch by tying two separate WritableStorage outputs together to the same LinkSystem.
Secondary items
v2/storage
package; no references tointernal/store
and did a bit of cleanup in the process.Option
s into the v2 so they can be shared, leavingvar
aliases for them so they shouldn't break for existing users.ErrNotFound
instead of using the go-ipld-format one (see last primary goal). This might be a bit controversial but in doing so I'm also documenting that users should prefer feature rather than type detection; they both have aIsNotFound() bool
on them which should be used instead. I've debated proposing we add this to go-ipld-prime/storage, maybe that's the next iteration here but the spirit of go-ipld-prime suggests that it may not fit so well there? It doesn't have an opinion (yet) on "not found" as a distinction.Other implementation notes
NewX()
to denote the creation of a fresh thing, so these don't use resumption logic, they start from scratch (NewWritable()
andNewReadableWritable()
). AndOpenX()
to denote something existing / resumed (OpenReadable()
andOpenReadableWritable()
- the resume version ofNewReadableWritable()
).OpenReadableWritable()
then you'll error if you can'tTruncate()
the IO object you've provided (i.e. you should be providing aFile
, but this doesn't preclude some other interface with that superpower). But you won't get an error for the same call where you request a v1.