Commit 6badef15 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: OpenStorage -> Open

For ZODB we always open database at storage level. Thus `zodb.Open(zurl)`
is relevant. At application level we open database creating DB from
IStorage and using DB.Open() .
parent 151d8b79
......@@ -143,7 +143,7 @@ func zhashMain(argv []string) {
func zhash(ctx context.Context, url string, h hasher, useprefetch bool, bench, check string) (err error) {
defer xerr.Context(&err, "zhash")
stor, err := zodb.OpenStorage(ctx, url, &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, url, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
return err
}
......@@ -394,7 +394,7 @@ func zwrkPreconnect(ctx context.Context, url string, at zodb.Tid, nwrk int) (_ [
ReadOnly: true,
NoCache: true,
}
stor, err := zodb.OpenStorage(ctx, url, &opts)
stor, err := zodb.Open(ctx, url, &opts)
if err != nil {
return err
}
......@@ -443,7 +443,7 @@ func zwrkPreconnect(ctx context.Context, url string, at zodb.Tid, nwrk int) (_ [
func zwrkPrepare(ctx context.Context, url string, h hasher, check string) (at zodb.Tid, objcheckv []uint32, err error) {
defer xerr.Context(&err, "zwrk/prepare")
stor, err := zodb.OpenStorage(ctx, url, &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, url, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
return 0, nil, err
}
......
......@@ -101,7 +101,7 @@ func (b *bucketWrap) MaxKey(ctx context.Context) (k int64, ok bool, err error) {
func TestBTree(t *testing.T) {
X := exc.Raiseif
ctx := context.Background()
stor, err := zodb.OpenStorage(ctx, "testdata/1.fs", &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, "testdata/1.fs", &zodb.OpenOptions{ReadOnly: true})
if err != nil {
t.Fatal(err)
}
......
......@@ -347,7 +347,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
// open connection to it via zodb/go
ctx := context.Background()
stor, err := OpenStorage(ctx, zurl, &OpenOptions{ReadOnly: true, NoCache: !rawcache}); X(err)
stor, err := Open(ctx, zurl, &OpenOptions{ReadOnly: true, NoCache: !rawcache}); X(err)
db := NewDB(stor)
defer func() {
err := db.Close(); X(err)
......
......@@ -32,7 +32,7 @@ import (
"lab.nexedi.com/kirr/go123/xcontext"
)
// OpenOptions describes options for OpenStorage.
// OpenOptions describes options for Open.
type OpenOptions struct {
ReadOnly bool // whether to open storage as read-only
NoCache bool // don't use cache for read/write operations; prefetch will be noop
......@@ -73,14 +73,14 @@ func RegisterDriver(scheme string, opener DriverOpener) {
driverRegistry[scheme] = opener
}
// OpenStorage opens ZODB storage by URL.
// Open opens ZODB storage by URL.
//
// Only URL schemes registered to zodb package are handled.
// Users should import in storage packages they use or zodb/wks package to
// get support for well-known storages.
//
// Storage authors should register their storages with RegisterStorage.
func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error) {
func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error) {
// no scheme -> file://
if !strings.Contains(zurl, "://") {
zurl = "file://" + zurl
......@@ -142,7 +142,7 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage,
// storage represents storage opened via OpenStorage.
// storage represents storage opened via Open.
//
// it provides a small cache on top of raw storage driver to implement prefetch
// and other storage-independed higher-level functionality.
......
......@@ -54,7 +54,7 @@
//
// Unless one is doing something FileStorage-specific, it is advised not to use
// fs1 package directly, and instead link-in lab.nexedi.com/kirr/neo/go/zodb/wks,
// open storage by zodb.OpenStorage and use it by way of zodb.IStorage interface.
// open storage by zodb.Open and use it by way of zodb.IStorage interface.
//
// The fs1 package exposes all FileStorage data format details and most of
// internal workings so that it is possible to implement FileStorage-specific
......
......@@ -55,7 +55,7 @@
// The storage layer provides access to a ZODB database in terms of database
// records with raw bytes payload.
//
// At storage level a ZODB database can be opened with OpenStorage. Once opened
// At storage level a ZODB database can be opened with Open. Once opened
// IStorage interface is returned that represents access to the database.
// Please see IStorage, and interfaces it embeds, for details.
//
......
......@@ -126,7 +126,7 @@ func catobjMain(argv []string) {
ctx := context.Background()
stor, err := zodb.OpenStorage(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
prog.Fatal(err)
}
......
......@@ -271,7 +271,7 @@ func dumpMain(argv []string) {
ctx := context.Background()
stor, err := zodb.OpenStorage(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
prog.Fatal(err)
}
......
// Copyright (C) 2016-2017 Nexedi SA and Contributors.
// Copyright (C) 2016-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -67,7 +67,7 @@ func loadZdumpPy(t *testing.T, path string) string {
}
func withTestdataFs(t testing.TB, db string, f func(zstor zodb.IStorage)) {
zstor, err := zodb.OpenStorage(context.Background(), fmt.Sprintf("../../zodb/storage/fs1/testdata/%s.fs", db), &zodb.OpenOptions{ReadOnly: true})
zstor, err := zodb.Open(context.Background(), fmt.Sprintf("../../zodb/storage/fs1/testdata/%s.fs", db), &zodb.OpenOptions{ReadOnly: true})
if err != nil {
t.Fatal(err)
}
......
......@@ -128,7 +128,7 @@ func infoMain(argv []string) {
ctx := context.Background()
stor, err := zodb.OpenStorage(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
prog.Fatal(err)
}
......
......@@ -154,7 +154,7 @@ func watchMain(argv []string) {
ctx := context.Background()
stor, err := zodb.OpenStorage(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
prog.Fatal(err)
}
......
......@@ -62,7 +62,7 @@ func TestWatch(t *testing.T) {
// open tfs at go side
bg := context.Background()
stor, err := zodb.OpenStorage(bg, tfs, &zodb.OpenOptions{ReadOnly: true}); X(err)
stor, err := zodb.Open(bg, tfs, &zodb.OpenOptions{ReadOnly: true}); X(err)
// spawn plain and verbose watchers
ctx0, cancel := context.WithCancel(bg)
......
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