Commit 619e2b3c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d3e124d1
...@@ -130,6 +130,12 @@ func newConnection(db *DB, at Tid) *Connection { ...@@ -130,6 +130,12 @@ func newConnection(db *DB, at Tid) *Connection {
} }
} }
// At returns database state corresponding to the connection.
func (conn *Connection) At() Tid {
conn.checkLive("at")
return conn.at
}
// wrongClassError is the error cause returned when ZODB object's class is not what was expected. // wrongClassError is the error cause returned when ZODB object's class is not what was expected.
type wrongClassError struct { type wrongClassError struct {
want, have string want, have string
...@@ -239,6 +245,14 @@ func (conn *Connection) checkTxnCtx(ctx context.Context, who string) { ...@@ -239,6 +245,14 @@ func (conn *Connection) checkTxnCtx(ctx context.Context, who string) {
// checkTxn asserts that specified "current" transaction is the same as conn.txn . // checkTxn asserts that specified "current" transaction is the same as conn.txn .
func (conn *Connection) checkTxn(txn transaction.Transaction, who string) { func (conn *Connection) checkTxn(txn transaction.Transaction, who string) {
if txn != conn.txn { if txn != conn.txn {
panic("connection: " + who + "current transaction is different from connection transaction") panic("connection: " + who + ": current transaction is different from connection transaction")
}
}
// checkLive asserts that the connection is alive - the transaction under which
// it has been opened is not yet complete.
func (conn *Connection) checkLive(who string) {
if conn.txn == nil {
panic("connection: " + who + ": connection is not live")
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment