Commit adb2ada3 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: Cosmetics

More comments, typos, ...
parent 1e6aeeee
...@@ -125,7 +125,10 @@ type LiveCache struct { ...@@ -125,7 +125,10 @@ type LiveCache struct {
} }
// LiveCacheControl is the interface that allows applications to influence // LiveCacheControl is the interface that allows applications to influence
// Connection's decisions with respect to Connection's live cache. // Connection's decisions with respect to Connection's LiveCache.
//
// See Connection.Cache and LiveCache.SetControl for how to install
// LiveCacheControl on a connection's live cache.
type LiveCacheControl interface { type LiveCacheControl interface {
// PCacheClassify is called to classify an object and returns live // PCacheClassify is called to classify an object and returns live
// cache policy that should be used for this object. // cache policy that should be used for this object.
...@@ -210,6 +213,7 @@ func (e *wrongClassError) Error() string { ...@@ -210,6 +213,7 @@ func (e *wrongClassError) Error() string {
// Get lookups object corresponding to oid in the cache. // Get lookups object corresponding to oid in the cache.
// //
// If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it. // If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it.
// LiveCacheControl can be used to extend that guarantee.
func (cache *LiveCache) Get(oid Oid) IPersistent { func (cache *LiveCache) Get(oid Oid) IPersistent {
// 1. lookup in pinned objects (likely hottest ones) // 1. lookup in pinned objects (likely hottest ones)
obj := cache.pinned[oid] obj := cache.pinned[oid]
......
...@@ -229,9 +229,9 @@ type tConnection struct { ...@@ -229,9 +229,9 @@ type tConnection struct {
*testing.T *testing.T
// a transaction and DB connection opened under it // a transaction and DB connection opened under it
txn transaction.Transaction txn transaction.Transaction
ctx context.Context ctx context.Context
conn *Connection conn *Connection
} }
// testdb creates and initializes new test database. // testdb creates and initializes new test database.
...@@ -597,8 +597,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) { ...@@ -597,8 +597,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t.checkObj(obj2, 102, InvalidTid, GHOST, 0) t.checkObj(obj2, 102, InvalidTid, GHOST, 0)
// obj2 data should be new // obj2 data should be new
t.PActivate(obj1); t.PActivate(obj1)
t.PActivate(obj2); t.PActivate(obj2)
t.checkObj(obj1, 101, at1, UPTODATE, 1, "hello") t.checkObj(obj1, 101, at1, UPTODATE, 1, "hello")
t.checkObj(obj2, 102, at2, UPTODATE, 1, "kitty") t.checkObj(obj2, 102, at2, UPTODATE, 1, "kitty")
...@@ -613,6 +613,9 @@ func testPersistentDB(t0 *testing.T, rawcache bool) { ...@@ -613,6 +613,9 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t2.Abort() t2.Abort()
assert.Equal(db.pool, []*Connection{t1.conn, t2.conn}) assert.Equal(db.pool, []*Connection{t1.conn, t2.conn})
// ---- Resync ----
// open new connection in nopool mode to verify resync // open new connection in nopool mode to verify resync
t4 := tdb.Open(&ConnOptions{NoPool: true}) t4 := tdb.Open(&ConnOptions{NoPool: true})
t = t4 t = t4
...@@ -685,7 +688,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) { ...@@ -685,7 +688,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t.checkObj(robj1, 101, InvalidTid, GHOST, 0) t.checkObj(robj1, 101, InvalidTid, GHOST, 0)
t.checkObj(robj2, 102, at2, UPTODATE, 0, "kitty") t.checkObj(robj2, 102, at2, UPTODATE, 0, "kitty")
// Resync ↓ (at1 -> at0; to outside δtail coverage) // Resync ↓ (at2 -> at0; to outside δtail coverage)
t.Abort() t.Abort()
assert.Equal(db.pool, []*Connection{t1.conn, t2.conn}) assert.Equal(db.pool, []*Connection{t1.conn, t2.conn})
t.Resync(at0) t.Resync(at0)
......
...@@ -118,7 +118,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error) ...@@ -118,7 +118,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
cache = NewCache(storDriver, 128 * 4*1024) cache = NewCache(storDriver, 128 * 4*1024)
// FIXME teach cache for watching and remove vvv // FIXME teach cache for watching and remove vvv
log.Printf("zodb: FIXME: open %s: cache is not ready for invalidations" + log.Printf("zodb: FIXME: open %s: raw cache is not ready for invalidations" +
" -> NoCache forced", zurl) " -> NoCache forced", zurl)
cache = nil cache = nil
} }
...@@ -135,7 +135,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error) ...@@ -135,7 +135,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
watchCancel: make(map[chan<- Event]chan struct{}), watchCancel: make(map[chan<- Event]chan struct{}),
} }
go stor.watcher() // stoped on close go stor.watcher() // stopped on close
return stor, nil return stor, nil
} }
...@@ -145,7 +145,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error) ...@@ -145,7 +145,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
// storage represents storage opened via Open. // storage represents storage opened via Open.
// //
// it provides a small cache on top of raw storage driver to implement prefetch // it provides a small cache on top of raw storage driver to implement prefetch
// and other storage-independed higher-level functionality. // and other storage-independent higher-level functionality.
type storage struct { type storage struct {
driver IStorageDriver driver IStorageDriver
l1cache *Cache // can be =nil, if opened with NoCache l1cache *Cache // can be =nil, if opened with NoCache
...@@ -281,7 +281,7 @@ func (s *storage) _watcher() error { ...@@ -281,7 +281,7 @@ func (s *storage) _watcher() error {
req.ack <- s.head req.ack <- s.head
} }
// close all subscribers's watchq on watcher shutdow // close all subscribers's watchq on watcher shutdown
defer func() { defer func() {
addqFlush() addqFlush()
for watchq := range s.watchTab { for watchq := range s.watchTab {
......
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