Commit 2f5e3606 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: Require DB to be closed

DB is a "handle to database". It has to be closed to release its
resources when no longer needed. We don't have to release anything
currently, but that will soon change in a followup patch.
parent f117335c
...@@ -106,6 +106,9 @@ func TestBTree(t *testing.T) { ...@@ -106,6 +106,9 @@ func TestBTree(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
db := zodb.NewDB(stor) db := zodb.NewDB(stor)
defer func() {
err := db.Close(); X(err)
}()
txn, ctx := transaction.New(ctx) txn, ctx := transaction.New(ctx)
defer txn.Abort() defer txn.Abort()
......
...@@ -65,11 +65,19 @@ type invEntry struct { ...@@ -65,11 +65,19 @@ type invEntry struct {
// NewDB creates new database handle. // NewDB creates new database handle.
//
// Created database handle must be closed when no longer needed.
func NewDB(stor IStorage) *DB { func NewDB(stor IStorage) *DB {
// XXX db options? // XXX db options?
return &DB{stor: stor} return &DB{stor: stor}
} }
// Close closes database handle.
func (db *DB) Close() error {
return nil
}
// ConnOptions describes options to DB.Open . // ConnOptions describes options to DB.Open .
type ConnOptions struct { type ConnOptions struct {
At Tid // if !0, open Connection bound to `at` view of database; not latest. At Tid // if !0, open Connection bound to `at` view of database; not latest.
......
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