Commit a520c82e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f7b570c2
...@@ -67,7 +67,7 @@ func TestBTree(t *testing.T) { ...@@ -67,7 +67,7 @@ func TestBTree(t *testing.T) {
txn, ctx := transaction.New(ctx) txn, ctx := transaction.New(ctx)
defer txn.Abort() defer txn.Abort()
conn, err := db.Open(ctx) conn, err := db.Open(ctx, &zodb.ConnOptions{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
......
...@@ -67,29 +67,43 @@ func NewDB(stor IStorage) *DB { ...@@ -67,29 +67,43 @@ func NewDB(stor IStorage) *DB {
return &DB{stor: stor} return &DB{stor: stor}
} }
// ConnOptions describes options to DB.Open .
type ConnOptions struct {
At Tid // if !0, open Connection bound to `at` view of database; not latest.
NoSync bool // don't sync with storage to get its last tid.
}
// Open opens new connection to the database. // Open opens new connection to the database.
// //
// The connection is opened to current latest database state. // By default the connection is opened to current latest database state; opt.At
// can be specified to open connection bound to particular view of the database.
// //
// Open must be called under transaction. // Open must be called under transaction.
// Opened connection must be used only under the same transaction and only // Opened connection must be used only under the same transaction and only
// until that transaction is complete. // until that transaction is complete.
// func (db *DB) Open(ctx context.Context, opt *ConnOptions) (*Connection, error) {
// XXX text
//
// XXX +OpenAt ?
func (db *DB) Open(ctx context.Context) (*Connection, error) {
// XXX err ctx // XXX err ctx
txn := transaction.Current(ctx) txn := transaction.Current(ctx)
// sync storage for lastTid at := opt.At
// XXX open option not to sync and just get lastTid as .invTab.Head() ? if at == 0 {
at, err := db.stor.LastTid(ctx) // XXX init head from current DB.head (head of .invTab)
if err != nil { var head Tid
return nil, err var err error
// sync storage for lastTid
if !opt.NoSync {
head, err = db.stor.LastTid(ctx)
if err != nil {
return nil, err
}
}
at = head
} }
// wait till .invTab is up to date covering ≥ lastTid // wait till .invTab is up to date covering ≥ lastTid
// XXX reenable // XXX reenable
/* /*
......
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