-
Notifications
You must be signed in to change notification settings - Fork 67
remove ThreadSafeDatastore #120
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It's a lie! We: 1. Assume that our datastores are thread-safe all over the place, not bothering to check for this interface. 2. Implement this interface for, e.g., the mount datastore that _may not_ be thread-safe (depending on the sub-datastores). Basically, there's no sane way to to do something like this in go. What we _want_ is: ```rust pub trait ThreadSafe {} struct MyWrapper<D: Datastore> { ... } impl<D: Datastore> ThreadSafe for MyWrapper<D> where D: ThreadSafe {} ``` Actually, we don't even need this because rust has already done all the hard work with the `Sync` trait. .... But we're using go which barely has types. --- For completeness, it's actually possible to do this in go: ```go type threadSafeMixin struct{} func (threadSafeMixin) ThreadSafe() {} func NewWrapper(d Datastore) Datastore { if _, ok := d.(ThreadSafe) { return &struct{myWrapper, threadSafeMixin}{myWrapper{d}, threadSafeMixin{}} } return &myWrapper{d} } ``` Let's not.
Stebalien
added a commit
to ipfs/go-ds-redis
that referenced
this pull request
Mar 15, 2019
Merge before: ipfs/go-datastore#120
Stebalien
added a commit
to ipfs/go-ds-flatfs
that referenced
this pull request
Mar 15, 2019
Merge before: ipfs/go-datastore#120
This was referenced Mar 15, 2019
Stebalien
added a commit
to ipfs/go-ds-badger
that referenced
this pull request
Mar 15, 2019
Merge before: ipfs/go-datastore#120
Stebalien
added a commit
to ipfs/go-ds-leveldb
that referenced
this pull request
Mar 15, 2019
Merge before: ipfs/go-datastore#120
magik6k
approved these changes
Mar 16, 2019
Heads up that this was a breaking API change and was released under a patch version bump (consider doing a minor release bump in that case, as most of us don't expect builds to break after |
You're right, I should have done that. I'm too used to versions meaning nothing at this point... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It's a lie! We:
Basically, there's no sane way to to do something like this in go. What we want is:
Actually, we don't even need this because rust has already done all the hard
work with the
Sync
trait.....
But we're using go which barely has types.
For completeness, it's actually possible to do this in go:
Let's not.
Merge first: