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

Add transactional support to leveldb datastore. #17

Merged
merged 3 commits into from
Sep 27, 2018
Merged

Conversation

raulk
Copy link
Member

@raulk raulk commented Sep 24, 2018

Merge ipfs/go-datastore#98 first.

@ghost ghost assigned raulk Sep 24, 2018
@ghost ghost added the status/in-progress In progress label Sep 24, 2018
@@ -130,7 +148,7 @@ func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) {
}), nil
}

func (d *datastore) QueryOrig(q dsq.Query) (dsq.Results, error) {
func (a *accessor) queryOrig(q dsq.Query) (dsq.Results, error) {
Copy link
Member Author

@raulk raulk Sep 24, 2018

Choose a reason for hiding this comment

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

The exported QueryOrig and QueryNew are not used in IPFS to my knowledge. I made them private, as it feels wrong for these to be exported, but feel free to push back if I shouldn't have.

Copy link

Choose a reason for hiding this comment

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

ah, there we go!

@@ -49,21 +54,34 @@ func NewDatastore(path string, opts *Options) (*datastore, error) {
}

return &datastore{
DB: db,
path: path,
accessor: &accessor{ldb: db},
Copy link
Member Author

Choose a reason for hiding this comment

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

This accessor is created with the LevelDB DB itself. The accessor on NewTransaction() is created with the transaction. I'm not married to the naming.

@raulk raulk requested a review from bigs September 24, 2018 23:13
func (d *datastore) Put(key ds.Key, value []byte) (err error) {
return d.DB.Put(key.Bytes(), value, nil)
// It allows to plug in either inside the `accessor`.
type levelDbOps interface {
Copy link

Choose a reason for hiding this comment

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

👍 🎉

}

func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) {
func (a *accessor) queryNew(q dsq.Query) (dsq.Results, error) {
Copy link

Choose a reason for hiding this comment

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

generally approve re-scoping this, but just make sure it's not breaking anything unexpectedly

@@ -130,7 +148,7 @@ func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) {
}), nil
}

func (d *datastore) QueryOrig(q dsq.Query) (dsq.Results, error) {
func (a *accessor) queryOrig(q dsq.Query) (dsq.Results, error) {
Copy link

Choose a reason for hiding this comment

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

ah, there we go!

@raulk raulk merged commit 13c8c18 into ipfs:master Sep 27, 2018
@raulk raulk deleted the txn branch September 27, 2018 16:33
@ghost ghost removed the status/in-progress In progress label Sep 27, 2018
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.

2 participants