-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
@@ -9,16 +8,16 @@ import ( | |||
) | |||
|
|||
type Session interface { | |||
db.Database | |||
db.Tx |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
Hello @pkieltyka! This patch adds transaction support. The |
this looks great! I think also add some tests to bond_test.go |
@@ -0,0 +1 @@ | |||
*.sw? |
There was a problem hiding this comment.
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.
Good point @pkieltyka, I just added them. |
Fixing context issues by passing the session to After* and Before* methods.
… all of them exit with status 0.
go: | ||
- 1.4 | ||
- 1.4.1 | ||
- 1.4.2 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! good catch, done.
This PR adds transaction support in bond using a new
NewTransaction()
method thats creates abond.Session
session that runs within a transaction context. The user can then useCommit()
andRollback()
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