Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
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
Stefane Fermigier
neo
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
Show 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 {
...
@@ -79,10 +79,9 @@ func (c *Client) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
// TODO read-only support
// 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 for now url is treated as storage node URL
// XXX check/use other url fields
// XXX check/use other url fields
ctx
:=
context
.
Background
()
// XXX ok?
storLink
,
err
:=
Dial
(
ctx
,
"tcp"
,
u
.
Host
)
storLink
,
err
:=
Dial
(
ctx
,
"tcp"
,
u
.
Host
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
go/neo/storage.go
View file @
2ab737be
...
@@ -210,7 +210,7 @@ func storageMain(argv []string) {
...
@@ -210,7 +210,7 @@ func storageMain(argv []string) {
}
}
// XXX hack to use existing zodb storage for data
// 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
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
...
...
go/zodb/open.go
View file @
2ab737be
...
@@ -19,13 +19,14 @@ package zodb
...
@@ -19,13 +19,14 @@ package zodb
// logic to open storages by URL
// logic to open storages by URL
import
(
import
(
"context"
"fmt"
"fmt"
"net/url"
"net/url"
"strings"
"strings"
)
)
// StorageOpener is a function to open a storage
// 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
// {} scheme -> StorageOpener
var
storageRegistry
=
map
[
string
]
StorageOpener
{}
var
storageRegistry
=
map
[
string
]
StorageOpener
{}
...
@@ -46,7 +47,7 @@ func RegisterStorage(scheme string, opener StorageOpener) {
...
@@ -46,7 +47,7 @@ func RegisterStorage(scheme string, opener StorageOpener) {
// Storage authors should register their storages with RegisterStorage
// Storage authors should register their storages with RegisterStorage
//
//
// TODO readonly
// TODO readonly
func
OpenStorageURL
(
storageURL
string
)
(
IStorage
,
error
)
{
func
OpenStorageURL
(
ctx
context
.
Context
,
storageURL
string
)
(
IStorage
,
error
)
{
// no scheme -> file://
// no scheme -> file://
if
!
strings
.
Contains
(
storageURL
,
"://"
)
{
if
!
strings
.
Contains
(
storageURL
,
"://"
)
{
storageURL
=
"file://"
+
storageURL
storageURL
=
"file://"
+
storageURL
...
@@ -62,5 +63,5 @@ func OpenStorageURL(storageURL string) (IStorage, error) {
...
@@ -62,5 +63,5 @@ func OpenStorageURL(storageURL string) (IStorage, error) {
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
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 @@
...
@@ -22,6 +22,7 @@
package
fs1
package
fs1
import
(
import
(
"context"
"encoding/binary"
"encoding/binary"
"fmt"
"fmt"
"io"
"io"
...
@@ -663,7 +664,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
...
@@ -663,7 +664,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
}
}
// Open opens FileStorage XXX text
// Open opens FileStorage XXX text
func
Open
(
path
string
)
(
*
FileStorage
,
error
)
{
func
Open
(
ctx
context
.
Context
,
path
string
)
(
*
FileStorage
,
error
)
{
fs
:=
&
FileStorage
{}
fs
:=
&
FileStorage
{}
f
,
err
:=
os
.
Open
(
path
)
// XXX opens in O_RDONLY
f
,
err
:=
os
.
Open
(
path
)
// XXX opens in O_RDONLY
...
@@ -682,7 +683,7 @@ func Open(path string) (*FileStorage, error) {
...
@@ -682,7 +683,7 @@ func Open(path string) (*FileStorage, error) {
return
nil
,
fmt
.
Errorf
(
"%s: invalid magic %q"
,
path
,
xxx
)
// XXX err?
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
// TODO verify index sane / topPos matches
topPos
,
index
,
err
:=
LoadIndexFile
(
path
+
".index"
)
topPos
,
index
,
err
:=
LoadIndexFile
(
path
+
".index"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
2ab737be
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
fs1
package
fs1
import
(
import
(
"context"
"fmt"
"fmt"
"io"
"io"
"reflect"
"reflect"
...
@@ -85,7 +86,7 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
...
@@ -85,7 +86,7 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
}
}
func
xfsopen
(
t
testing
.
TB
,
path
string
)
*
FileStorage
{
func
xfsopen
(
t
testing
.
TB
,
path
string
)
*
FileStorage
{
fs
,
err
:=
Open
(
path
)
fs
,
err
:=
Open
(
context
.
Background
(),
path
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
go/zodb/storage/fs1/url.go
View file @
2ab737be
...
@@ -19,16 +19,17 @@ package fs1
...
@@ -19,16 +19,17 @@ package fs1
// open URL support
// open URL support
import
(
import
(
"context"
"net/url"
"net/url"
"../../../zodb"
"../../../zodb"
)
)
// TODO read-only support
// 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
// TODO handle query
// XXX u.Path is not always raw path - recheck and fix
// 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
()
{
func
init
()
{
...
...
go/zodb/zodbtools/catobj.go
View file @
2ab737be
...
@@ -19,6 +19,7 @@ package zodbtools
...
@@ -19,6 +19,7 @@ package zodbtools
// Catobj - dump content of a database object
// Catobj - dump content of a database object
import
(
import
(
"context"
"flag"
"flag"
"fmt"
"fmt"
"io"
"io"
...
@@ -116,7 +117,7 @@ func catobjMain(argv []string) {
...
@@ -116,7 +117,7 @@ func catobjMain(argv []string) {
log
.
Fatal
(
"only 1 object allowed with -raw"
)
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
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
...
...
go/zodb/zodbtools/dump.go
View file @
2ab737be
...
@@ -37,6 +37,7 @@ txn ...
...
@@ -37,6 +37,7 @@ txn ...
package
zodbtools
package
zodbtools
import
(
import
(
"context"
"crypto/sha1"
"crypto/sha1"
"flag"
"flag"
"fmt"
"fmt"
...
@@ -245,7 +246,7 @@ func dumpMain(argv []string) {
...
@@ -245,7 +246,7 @@ func dumpMain(argv []string) {
log
.
Fatal
(
err
)
// XXX recheck
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
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
...
...
go/zodb/zodbtools/dump_test.go
View file @
2ab737be
...
@@ -21,6 +21,7 @@ package zodbtools
...
@@ -21,6 +21,7 @@ package zodbtools
import
(
import
(
"bytes"
"bytes"
"context"
"io/ioutil"
"io/ioutil"
"regexp"
"regexp"
"testing"
"testing"
...
@@ -72,7 +73,7 @@ func loadZdumpPy(t *testing.T, path string) string {
...
@@ -72,7 +73,7 @@ func loadZdumpPy(t *testing.T, path string) string {
func
withTestdata1Fs
(
t
testing
.
TB
,
f
func
(
fs
*
fs1
.
FileStorage
))
{
func
withTestdata1Fs
(
t
testing
.
TB
,
f
func
(
fs
*
fs1
.
FileStorage
))
{
// XXX -> zodb.OpenURL
// 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
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
go/zodb/zodbtools/info.go
View file @
2ab737be
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
package
zodbtools
package
zodbtools
import
(
import
(
"context"
"flag"
"flag"
"fmt"
"fmt"
"io"
"io"
...
@@ -113,7 +114,7 @@ func infoMain(argv []string) {
...
@@ -113,7 +114,7 @@ func infoMain(argv []string) {
}
}
storUrl
:=
argv
[
0
]
storUrl
:=
argv
[
0
]
stor
,
err
:=
zodb
.
OpenStorageURL
(
storUrl
)
// TODO read-only
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
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