diff --git a/kvs/boltdb/tx.go b/kvs/boltdb/tx.go index e1b03f68..82b0d3c6 100644 --- a/kvs/boltdb/tx.go +++ b/kvs/boltdb/tx.go @@ -28,6 +28,7 @@ import ( // TX is a distributed database transaction. type TX struct { ds *DS + do bool ck []byte tx *bolt.Tx bu *bolt.Bucket @@ -329,6 +330,10 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { } +func (tx *TX) Done() (val bool) { + return tx.do +} + func (tx *TX) Close() (err error) { return tx.Rollback() } @@ -338,6 +343,7 @@ func (tx *TX) Cancel() (err error) { } func (tx *TX) Commit() (err error) { + tx.do = true if tx.tx.Writable() { return tx.tx.Commit() } @@ -345,6 +351,7 @@ func (tx *TX) Commit() (err error) { } func (tx *TX) Rollback() (err error) { + tx.do = true return tx.tx.Rollback() } diff --git a/kvs/mysql/tx.go b/kvs/mysql/tx.go index 31fffc56..0d106ed3 100644 --- a/kvs/mysql/tx.go +++ b/kvs/mysql/tx.go @@ -28,6 +28,7 @@ import ( // TX is a distributed database transaction. type TX struct { ds *DS + do bool ck []byte tx *sql.Tx } @@ -310,6 +311,10 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { } +func (tx *TX) Done() (val bool) { + return tx.do +} + func (tx *TX) Close() (err error) { return tx.Rollback() } @@ -319,10 +324,12 @@ func (tx *TX) Cancel() (err error) { } func (tx *TX) Commit() (err error) { + tx.do = true return tx.tx.Commit() } func (tx *TX) Rollback() (err error) { + tx.do = true return tx.tx.Rollback() } diff --git a/kvs/pgsql/tx.go b/kvs/pgsql/tx.go index 71b00c4e..1f2d48b3 100644 --- a/kvs/pgsql/tx.go +++ b/kvs/pgsql/tx.go @@ -28,6 +28,7 @@ import ( // TX is a distributed database transaction. type TX struct { ds *DS + do bool ck []byte tx *sql.Tx } @@ -319,6 +320,10 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { } +func (tx *TX) Done() (val bool) { + return tx.do +} + func (tx *TX) Close() (err error) { return tx.Rollback() } @@ -328,10 +333,12 @@ func (tx *TX) Cancel() (err error) { } func (tx *TX) Commit() (err error) { + tx.do = true return tx.tx.Commit() } func (tx *TX) Rollback() (err error) { + tx.do = true return tx.tx.Rollback() } diff --git a/kvs/tx.go b/kvs/tx.go index d003e325..9b37117d 100644 --- a/kvs/tx.go +++ b/kvs/tx.go @@ -28,6 +28,7 @@ type TX interface { MDel(...[]byte) error PDel([]byte) error RDel([]byte, []byte, uint64) error + Done() bool Close() error Cancel() error Commit() error