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

Rename stores #136

Merged
merged 3 commits into from
Jun 4, 2017
Merged

Rename stores #136

merged 3 commits into from
Jun 4, 2017

Conversation

justinmchase
Copy link
Contributor

@justinmchase justinmchase commented Jun 4, 2017

I'm intending to add a new abstraction for s3 file storage (#135). This is simply a straight up refactor to rename the stores based on their purpose rather than the names of the kinds of storage. In other words, instead of fs and level the stores are renamed to block and data.

The s3 storage type will be in another repo and will be very similar to the fs datastore but saving into s3.

Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

This makes total sense @justinmchase. Thank you!

Do you happen to be working on a S3 backend?

@daviddias daviddias merged commit e54c5a2 into ipfs:master Jun 4, 2017
daviddias added a commit that referenced this pull request Jun 4, 2017
fix: remove the extensions .data that got introduced by #136
Copy link
Member

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

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

I am sorry, but I will have to revert this PR, there are quite a few changes that will break the functionality of this module

}])
const DataStore = this.options.dataStore
const dataStore = new DataStore(path.join(this.path, dataStoreDirectory), this.options.dataStoreOptions)
log(dataStore)
Copy link
Member

Choose a reason for hiding this comment

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

this should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

level: require('memdown'),
lock: 'memory'
const repos = [
{
Copy link
Member

Choose a reason for hiding this comment

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

please don't change code style, this makes it hard to read the diff

const repos = [{
name: 'default',
opts: undefined,
init: false
Copy link
Member

Choose a reason for hiding this comment

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

why was this removed?

opts: {
fs: require('interface-datastore').MemoryDatastore,
level: require('memdown'),
lock: 'memory'
Copy link
Member

Choose a reason for hiding this comment

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

why was this removed?

before((done) => {
series([
(cb) => {
if (r.init) {
Copy link
Member

Choose a reason for hiding this comment

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

why are you removing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For a bad reason. Basically I thought it was an inconsistency in the way the stores were getting created and a bug in this test but now I see that the tests were failing because I dropped the extension: '' from the store options which was making the fs based tests fail because it couldn't find the files copied in the before step. Adding the extension back and reverting basically this whole file resolves it.

this._fsOptions = Object.assign({}, options.fsOptions)
const FsStore = this.options.fs
this._fsStore = new FsStore(this.path, Object.assign({}, this._fsOptions, {
extension: ''
Copy link
Member

Choose a reason for hiding this comment

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

you can't just remove options that are important

Copy link
Member

Choose a reason for hiding this comment

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

I fixed this in #138

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, that was missed when moving options into default options objects.

this._fsStore = new FsStore(this.path, Object.assign({}, this._fsOptions, {
extension: ''
}))
this.options = Object.assign({ lock: 'memory', sharding: true }, options || defaultOptions)
Copy link
Member

Choose a reason for hiding this comment

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

lock still needs to be fs not memory

Copy link
Contributor Author

@justinmchase justinmchase Jun 5, 2017

Choose a reason for hiding this comment

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

Question about this. The fs lock appears to not use the datastore but to use fs api's directly. Supposing you were going to use a virtual file storage, and not the local file system, such as s3 would you still want a file system lock? It's not that the file system is completely off limits from writing to but the machine can get taken down and back up and the file system is ephemeral with the instance. Should the lock file also be stored on external storage or is it tied to the life cycle of the process?

Is its purpose to prevent other apps from writing the same files and if so shouldn't the lock actually be in the one of the stores?

@justinmchase
Copy link
Contributor Author

I updated my branch by adding the extension: '' option back onto the BlockStore in the constructor which also allowed me to revert the init changes to the tests.

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.

3 participants