-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add TTL and Transactional interfaces #91
Conversation
datastore.go
Outdated
} | ||
|
||
// Txn is an interface for transactions that can be committed or rolled back. | ||
type Txn interface { |
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.
Maybe just Tx
since the datastore is TxDatastore
?
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.
went the other way, but made them consistent!
datastore.go
Outdated
|
||
// Txn is an interface for transactions that can be committed or rolled back. | ||
type Txn interface { | ||
Datastore |
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.
Not sure if we want to say that txn should implement stuff like Query
. Feels a bit badger specific.
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.
the reasoning here is that updating values (i.e. reading an existing value and manipulating it) is pretty essential to most transactional behavior. without query support you just have the existing Batching
interface.
renamed Rollback -> Discard and made some docstrings |
datastore.go
Outdated
// queries and mutations to the Datastore into atomic groups, or transactions. | ||
// Actions performed on a transaction will not take hold until a successful | ||
// call to Commit has been made. Likewise, transactions can be aborted by | ||
// calling Discard before a successful Commit has been made. |
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.
This comment should be above the type Txn interface
line.
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.
Yes, and maybe this could be named (edit: that already exists.)TxnDatastore
.
datastore.go
Outdated
Get(key Key) (value interface{}, err error) | ||
Has(key Key) (exists bool, err error) | ||
Delete(key Key) error | ||
Query(q query.Query) (query.Results, error) |
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.
I'd rather extend Datastore
here so we avoid duplicating these
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.
so i generally agree, though this change was made in response to discussion happening in the badger impl, specifically right here. what do you think? the idea was to make it clear that this is happening in the Txn
not directly on the Datastore
. open to either
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.
The rationale behind this is that Txn
is not extending the Datastore
interface but is actually redefining it (committing is not an optional new feature, it's mandatory for the Put
to take effect). I agree that this solution is also not ideal, seems to me the lesser of the two evils, but I'm okay if you want to use Datastore
here.
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.
further thoughts on this? think we're pretty close!
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.
Hey @bigs, I think neither @magik6k nor myself have a strong feeling towards any of the proposed solutions, so it's your call, both solutions are fine by me. @Stebalien Do you any preferences here?
datastore.go
Outdated
// queries and mutations to the Datastore into atomic groups, or transactions. | ||
// Actions performed on a transaction will not take hold until a successful | ||
// call to Commit has been made. Likewise, transactions can be aborted by | ||
// calling Discard before a successful Commit has been made. |
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.
Yes, and maybe this could be named (edit: that already exists.)TxnDatastore
.
datastore.go
Outdated
Get(key Key) (value interface{}, err error) | ||
Has(key Key) (exists bool, err error) | ||
Delete(key Key) error | ||
Query(q query.Query) (query.Results, error) |
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.
The rationale behind this is that Txn
is not extending the Datastore
interface but is actually redefining it (committing is not an optional new feature, it's mandatory for the Put
to take effect). I agree that this solution is also not ideal, seems to me the lesser of the two evils, but I'm okay if you want to use Datastore
here.
OK, i'm going to revert this to extend |
This reverts commit 8cca168.
e03716c
to
7db32f2
Compare
adds two
Datastore
superclasses,TTLDatastore
andTxDatastore
. together, these give us pretty complete access to datastores such as badger.closes #87 and simplifies a slew of other issues as well.