Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
2ab737be
Commit
2ab737be
authored
May 02, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Add cancelling context to zodb.OpenStorageURL
parent
5bb19440
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
22 additions
and
15 deletions
+22
-15
go/neo/client.go
go/neo/client.go
+1
-2
go/neo/storage.go
go/neo/storage.go
+1
-1
go/zodb/open.go
go/zodb/open.go
+4
-3
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+3
-2
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+2
-1
go/zodb/storage/fs1/url.go
go/zodb/storage/fs1/url.go
+3
-2
go/zodb/zodbtools/catobj.go
go/zodb/zodbtools/catobj.go
+2
-1
go/zodb/zodbtools/dump.go
go/zodb/zodbtools/dump.go
+2
-1
go/zodb/zodbtools/dump_test.go
go/zodb/zodbtools/dump_test.go
+2
-1
go/zodb/zodbtools/info.go
go/zodb/zodbtools/info.go
+2
-1
No files found.
go/neo/client.go
View file @
2ab737be
...
...
@@ -79,10 +79,9 @@ func (c *Client) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
// TODO read-only support
func
openClientByURL
(
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
func
openClientByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
// XXX for now url is treated as storage node URL
// XXX check/use other url fields
ctx
:=
context
.
Background
()
// XXX ok?
storLink
,
err
:=
Dial
(
ctx
,
"tcp"
,
u
.
Host
)
if
err
!=
nil
{
return
nil
,
err
...
...
go/neo/storage.go
View file @
2ab737be
...
...
@@ -210,7 +210,7 @@ func storageMain(argv []string) {
}
// XXX hack to use existing zodb storage for data
zstor
,
err
:=
fs1
.
Open
(
argv
[
0
])
zstor
,
err
:=
fs1
.
Open
(
context
.
Background
(),
argv
[
0
])
// XXX context.Background -> ?
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
go/zodb/open.go
View file @
2ab737be
...
...
@@ -19,13 +19,14 @@ package zodb
// logic to open storages by URL
import
(
"context"
"fmt"
"net/url"
"strings"
)
// StorageOpener is a function to open a storage
type
StorageOpener
func
(
u
*
url
.
URL
)
(
IStorage
,
error
)
type
StorageOpener
func
(
ctx
context
.
Context
,
u
*
url
.
URL
)
(
IStorage
,
error
)
// {} scheme -> StorageOpener
var
storageRegistry
=
map
[
string
]
StorageOpener
{}
...
...
@@ -46,7 +47,7 @@ func RegisterStorage(scheme string, opener StorageOpener) {
// Storage authors should register their storages with RegisterStorage
//
// TODO readonly
func
OpenStorageURL
(
storageURL
string
)
(
IStorage
,
error
)
{
func
OpenStorageURL
(
ctx
context
.
Context
,
storageURL
string
)
(
IStorage
,
error
)
{
// no scheme -> file://
if
!
strings
.
Contains
(
storageURL
,
"://"
)
{
storageURL
=
"file://"
+
storageURL
...
...
@@ -62,5 +63,5 @@ func OpenStorageURL(storageURL string) (IStorage, error) {
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
}
return
opener
(
u
)
return
opener
(
ctx
,
u
)
}
go/zodb/storage/fs1/filestorage.go
View file @
2ab737be
...
...
@@ -22,6 +22,7 @@
package
fs1
import
(
"context"
"encoding/binary"
"fmt"
"io"
...
...
@@ -663,7 +664,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
}
// Open opens FileStorage XXX text
func
Open
(
path
string
)
(
*
FileStorage
,
error
)
{
func
Open
(
ctx
context
.
Context
,
path
string
)
(
*
FileStorage
,
error
)
{
fs
:=
&
FileStorage
{}
f
,
err
:=
os
.
Open
(
path
)
// XXX opens in O_RDONLY
...
...
@@ -682,7 +683,7 @@ func Open(path string) (*FileStorage, error) {
return
nil
,
fmt
.
Errorf
(
"%s: invalid magic %q"
,
path
,
xxx
)
// XXX err?
}
// TODO recreate index if missing / not sane
// TODO recreate index if missing / not sane
(cancel this job on ctx.Done)
// TODO verify index sane / topPos matches
topPos
,
index
,
err
:=
LoadIndexFile
(
path
+
".index"
)
if
err
!=
nil
{
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
2ab737be
...
...
@@ -18,6 +18,7 @@
package
fs1
import
(
"context"
"fmt"
"io"
"reflect"
...
...
@@ -85,7 +86,7 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
}
func
xfsopen
(
t
testing
.
TB
,
path
string
)
*
FileStorage
{
fs
,
err
:=
Open
(
path
)
fs
,
err
:=
Open
(
context
.
Background
(),
path
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
go/zodb/storage/fs1/url.go
View file @
2ab737be
...
...
@@ -19,16 +19,17 @@ package fs1
// open URL support
import
(
"context"
"net/url"
"../../../zodb"
)
// TODO read-only support
func
openByURL
(
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
func
openByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
// TODO handle query
// XXX u.Path is not always raw path - recheck and fix
return
Open
(
u
.
Host
+
u
.
Path
)
return
Open
(
ctx
,
u
.
Host
+
u
.
Path
)
}
func
init
()
{
...
...
go/zodb/zodbtools/catobj.go
View file @
2ab737be
...
...
@@ -19,6 +19,7 @@ package zodbtools
// Catobj - dump content of a database object
import
(
"context"
"flag"
"fmt"
"io"
...
...
@@ -116,7 +117,7 @@ func catobjMain(argv []string) {
log
.
Fatal
(
"only 1 object allowed with -raw"
)
}
stor
,
err
:=
zodb
.
OpenStorageURL
(
storUrl
)
// TODO read-only
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
go/zodb/zodbtools/dump.go
View file @
2ab737be
...
...
@@ -37,6 +37,7 @@ txn ...
package
zodbtools
import
(
"context"
"crypto/sha1"
"flag"
"fmt"
...
...
@@ -245,7 +246,7 @@ func dumpMain(argv []string) {
log
.
Fatal
(
err
)
// XXX recheck
}
stor
,
err
:=
zodb
.
OpenStorageURL
(
storUrl
)
// TODO read-only
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
go/zodb/zodbtools/dump_test.go
View file @
2ab737be
...
...
@@ -21,6 +21,7 @@ package zodbtools
import
(
"bytes"
"context"
"io/ioutil"
"regexp"
"testing"
...
...
@@ -72,7 +73,7 @@ func loadZdumpPy(t *testing.T, path string) string {
func
withTestdata1Fs
(
t
testing
.
TB
,
f
func
(
fs
*
fs1
.
FileStorage
))
{
// XXX -> zodb.OpenURL
fs
,
err
:=
fs1
.
Open
(
"../../zodb/storage/fs1/testdata/1.fs"
)
// XXX read-only, path?
fs
,
err
:=
fs1
.
Open
(
context
.
Background
(),
"../../zodb/storage/fs1/testdata/1.fs"
)
// XXX read-only, path?
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
go/zodb/zodbtools/info.go
View file @
2ab737be
...
...
@@ -20,6 +20,7 @@
package
zodbtools
import
(
"context"
"flag"
"fmt"
"io"
...
...
@@ -113,7 +114,7 @@ func infoMain(argv []string) {
}
storUrl
:=
argv
[
0
]
stor
,
err
:=
zodb
.
OpenStorageURL
(
storUrl
)
// TODO read-only
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment