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

Transaction support #5

Merged
merged 20 commits into from
Sep 8, 2015
Merged

Transaction support #5

merged 20 commits into from
Sep 8, 2015

Conversation

xiam
Copy link
Member

@xiam xiam commented Aug 25, 2015

This PR adds transaction support in bond using a new NewTransaction() method thats creates a bond.Session session that runs within a transaction context. The user can then use Commit() and Rollback() methods to save or discard the changes introduces in such session.

This may be a small PR but it actually took me a while to simplify the required changes :).

See: #4

@@ -9,16 +8,16 @@ import (
)

type Session interface {
db.Database
db.Tx
Copy link
Member Author

Choose a reason for hiding this comment

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

Same methods as Database, plus Commit() and Rollback().

func (s *store) Append(item interface{}) (interface{}, error) {
// Tx returns a copy of the store that runs in the context of the given
// transaction.
func (s *store) Tx(tx db.Tx) Store {
Copy link
Member Author

Choose a reason for hiding this comment

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

Returns a new store within the given transaction context.

@xiam
Copy link
Member Author

xiam commented Aug 25, 2015

Hello @pkieltyka! This patch adds transaction support. The bond.Store.Tx() was added to allow stores to put themselves within a transaction context. How do you see it?

@pkieltyka
Copy link
Member

this looks great! I think also add some tests to bond_test.go

@@ -0,0 +1 @@
*.sw?
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignoring vim's swap file.

@xiam
Copy link
Member Author

xiam commented Aug 25, 2015

Good point @pkieltyka, I just added them.

go:
- 1.4
- 1.4.1
- 1.4.2
Copy link
Member

Choose a reason for hiding this comment

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

can you add - 1.5 please

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah! good catch, done.

pkieltyka pushed a commit that referenced this pull request Sep 8, 2015
@pkieltyka pkieltyka merged commit 6699f26 into master Sep 8, 2015
@xiam xiam deleted the issue-4 branch July 29, 2016 12:16
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