Commit fcab58ca authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: Connection += .At()

To know database state corresponding to the connection.
parent 9112f21e
......@@ -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.
type wrongClassError struct {
want, have string
......@@ -238,3 +244,11 @@ func (conn *Connection) checkTxn(txn transaction.Transaction, who string) {
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