Commit 49581d4b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d731fd4e
......@@ -49,41 +49,41 @@ type Storage struct {
// Close implements zodb.IStorageDriver .
func (ovl *Storage) Close() error { // XXX ovl -> d ?
func (d *Storage) Close() error {
// XXX errctx?
err1 := ovl.δ.Close()
err2 := ovl.base.Close()
err1 := d.δ.Close()
err2 := d.base.Close()
// XXX close base watcher
return xerr.Merge(err1, err2)
}
// Sync implements zodb.IStorageDriver .
func (ovl *Storage) Sync(ctx context.Context) (head zodb.Tid, _ error) {
func (d *Storage) Sync(ctx context.Context) (head zodb.Tid, _ error) {
// XXX errctx?
head, err := ovl.δ.Sync(ctx)
head, err := d.δ.Sync(ctx)
if err != nil {
return zodb.InvalidTid, err
}
// δ is just created database
if head == 0 {
head = ovl.baseAt0
head = d.baseAt0
}
return head, nil
}
// Load implements zodb.IStorageDriver .
func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (_ *mem.Buf, _ zodb.Tid, err error) {
func (d *Storage) Load(ctx context.Context, xid zodb.Xid) (_ *mem.Buf, _ zodb.Tid, err error) {
defer func() {
if err != nil {
err = &zodb.OpError{URL: ovl.URL(), Op: "load", Args: xid, Err: err}
err = &zodb.OpError{URL: d.URL(), Op: "load", Args: xid, Err: err}
}
}()
data, serial, err := ovl.δ.Load(ctx, xid)
data, serial, err := d.δ.Load(ctx, xid)
if err == nil {
// object data is present in δ
return data, serial, nil
......@@ -114,7 +114,7 @@ func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (_ *mem.Buf, _ zodb.
}
// XXX cap .at in xid to base.At0 ? (and convert back on error return)
data, serial, err = ovl.base.Load(ctx, xid)
data, serial, err = d.base.Load(ctx, xid)
if err == nil {
return data, serial, nil
}
......@@ -135,14 +135,14 @@ func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (_ *mem.Buf, _ zodb.
}
// Iterator implements zodb.IStorageDriver .
func (ovl *Storage) Iterate(ctx context.Context, tidMin, tidMax zodb.Tid) zodb.ITxnIterator {
func (d *Storage) Iterate(ctx context.Context, tidMin, tidMax zodb.Tid) zodb.ITxnIterator {
// XXX errctx?
panic("TODO") // XXX
}
// URL implements zodb.IStorageDriver .
func (ovl *Storage) URL() string {
return "demo:(" + ovl.base.URL() + ")/(" + ovl.δ.URL() + ")"
func (d *Storage) URL() string {
return "demo:(" + d.base.URL() + ")/(" + d.δ.URL() + ")"
}
var demoRe = regexp.MustCompile(`^\((.*)\)/\((.*)\)$`)
......@@ -219,14 +219,14 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
}
// XXX listen on baseWatchq and shutdown storage if base changes.
ovl := &Storage{
d := &Storage{
base: base,
δ : δ,
baseAt0: baseAt0,
}
return ovl, at0, nil
return d, at0, nil
}
func init() {
......
......@@ -170,6 +170,8 @@ func TestWatch(t *testing.T) {
}
// TODO change base -> demo shutdown
func demoOpen(zurl string, opt *zodb.DriverOptions) (_ *Storage, at0 zodb.Tid, err error) {
defer xerr.Contextf(&err, "opendemo %s", zurl)
u, err := url.Parse(zurl)
......
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