Commit 16db7baf authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: Don't automatically inherit IStorageDriver methods

storage is a wrapper that turns IStorageDriver into IStorage. It will
have some logic around almost all IStorageDriver methods. So don't
automatically inherit driver methods not to miss some.
parent 0b488149
...@@ -115,7 +115,7 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, ...@@ -115,7 +115,7 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage,
} }
return &storage{ return &storage{
IStorageDriver: storDriver, driver: storDriver,
l1cache: cache, l1cache: cache,
}, nil }, nil
} }
...@@ -127,20 +127,34 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, ...@@ -127,20 +127,34 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage,
// 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-independed higher-level functionality.
type storage struct { type storage struct {
IStorageDriver driver IStorageDriver
l1cache *Cache // can be =nil, if opened with NoCache l1cache *Cache // can be =nil, if opened with NoCache
} }
func (s *storage) URL() string { return s.driver.URL() }
func (s *storage) Iterate(ctx context.Context, tidMin, tidMax Tid) ITxnIterator {
return s.driver.Iterate(ctx, tidMin, tidMax)
}
func (s *storage) Close() error {
return s.driver.Close()
}
// loading goes through cache - this way prefetching can work // loading goes through cache - this way prefetching can work
func (s *storage) LastTid(ctx context.Context) (Tid, error) {
return s.driver.LastTid(ctx)
}
func (s *storage) Load(ctx context.Context, xid Xid) (*mem.Buf, Tid, error) { func (s *storage) Load(ctx context.Context, xid Xid) (*mem.Buf, Tid, error) {
// XXX here: offload xid validation from cache and driver ? // XXX here: offload xid validation from cache and driver ?
// XXX here: offload wrapping err -> OpError{"load", err} ? // XXX here: offload wrapping err -> OpError{"load", err} ?
if s.l1cache != nil { if s.l1cache != nil {
return s.l1cache.Load(ctx, xid) return s.l1cache.Load(ctx, xid)
} else { } else {
return s.IStorageDriver.Load(ctx, xid) return s.driver.Load(ctx, xid)
} }
} }
......
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