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

Define GCDatastore/CheckedDatastore interfaces #68

Merged
merged 4 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.2: QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG
1.3.0: QmTWw8RaXEE155hrm8GiMYAYoUrAMwi6qt72CBpzdeGq1s
17 changes: 17 additions & 0 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,26 @@ var ErrBatchUnsupported = errors.New("this datastore does not support batching")
// implement to leverage type safety checks.
type ThreadSafeDatastore interface {
Datastore

IsThreadSafe()
}

// CheckedDatastore is an interface that should be implemented by datastores
// which may need checking on-disk data integrity.
type CheckedDatastore interface {
Datastore

Check() error
Copy link
Member

Choose a reason for hiding this comment

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

Maybe Scrub()? We also want to support datastores that can do error correction (where an error is returned iff the datastore is unrecoverable).

An open question is how do deal with partial failures. It would nice to be able to recover as much data as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Check would be invoked by ipfs repo fsck, which for now only removes lock files.

Scrub() does make sense (it could be wired up to ipfs repo verify, to keep repo fsck fast). Does putting this into separate interface SGTY (keeping check for stuff like lock-files)?

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Yes, having a separate interface sounds good.

Just to make sure, I assume Check() will find and fix any errors related to daemon crashes (i.e., it doesn't just blindly remove the lock file)?


Side note: we should get rid of ipfs repo fsck; IPFS should do any recovery necessary on startup automatically.

}

// GCDatastore is an interface that should be implemented by datastores which
// don't free disk space by just removing data from them
type GCDatastore interface {
Datastore

CollectGarbage() error
}

// Errors

// ErrNotFound is returned by Get, Has, and Delete when a datastore does not
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"license": "MIT",
"name": "go-datastore",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.2.2"
"version": "1.3.0"
}