Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

feat: allow overriding of internal functions #48

Merged
merged 2 commits into from
Jan 15, 2020

Conversation

achingbrain
Copy link
Collaborator

The interesting bits of this module are the various ways of building DAGs for files and folders (flat, sharded, etc).

Sometimes we want to utilise bits of this logic to build DAGs without having to reimplement big chunks of this module.

This PR allows the user to pass in functions to replace key parts of this import pipeline.

Enables:

The interesting bits of this module are the various ways of building
DAGs for files and folders (flat, sharded, etc).

Sometimes we want to utilise bits of this logic to build DAGs without
having to reimplement big chunks of this module.

This PR allows the user to pass in functions to replace key parts of
this import pipeline.

Enables:

* ipfs-inactive/js-ipfs-mfs#73
* #46
@achingbrain
Copy link
Collaborator Author

@mikeal I think this should allow you to accomplish #45 and #46 - see the tests here largely 'inspired' by the tests added to those PRs.

It does it in a way that lets me do ipfs-inactive/js-ipfs-mfs#73 using the same mechanism.

@achingbrain achingbrain requested a review from alanshaw January 13, 2020 16:22
@mikeal
Copy link

mikeal commented Jan 14, 2020

I pulled down the branch and wrote what I need against it and can say for certain that it works and does what I need. +1

Copy link
Contributor

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Changes LGTM

@@ -145,8 +146,28 @@ The input's file paths and directory structure will be preserved in the [`dag-pb
- `blockWriteConcurrency` (positive integer, defaults to 10) How many blocks to hash and write to the block store concurrently. For small numbers of large files this should be high (e.g. 50).
- `fileImportConcurrency` (number, defaults to 50) How many files to import concurrently. For large numbers of small files this should be high (e.g. 50).

## Overriding internals

Several aspects of the importer are overridable by specifying functions as part of the options object with these keys:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be useful to know the role of each of these in addition to their signature and return type. It’s great that they can be overridden but I don’t see why/how a user can use it without knowing what part these functions play in the import process.

@achingbrain achingbrain merged commit 0bff5f2 into master Jan 15, 2020
@achingbrain achingbrain deleted the expose-internals-for-customisation branch January 15, 2020 10:51
@achingbrain
Copy link
Collaborator Author

Released as v0.44.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants