feat!: accept pre-configured import components as options instead of options for components #283
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.
The existing importer takes one big options object that contains options for every subsystem. This leads to situations where different components use the same option keys - for example both the rabin and fixed-size chunkers use the
maxChunkSize
key.This PR reduces the number of options by accepting preconfigured instances of internal components - e.g. instead of passing
'"rabin"
for the chunker argument, you pass an instance of the rabin chunker instead. This greatly simplifies the config and also allows a simple way for users to pass custom chunkers in. The same thing applies to file layouts, dag builders etc.Before:
After:
Other breaking changes:
onlyHash
option has been removed - just pass aMemoryBlockstore
or other blockstore implementation that doesn't store the blocks anywherestrategy
config key is nowlayout
and accepts an instance of a file layout instead of a stringchunker
config key now accepts an instance of a file chunker instead of a stringimportFile
,importDirectory
,importBytes
andimportByteStream
functions are also now exported along sideimporter
to make dealing with simple imports that only import one thing easier.BREAKING CHANGE: The options object now accepts preconfigured instances of chunkers and file layouts - these can be imported from this module - see #283 for more