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
26e8e3d3
Commit
26e8e3d3
authored
Dec 18, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
96ed5401
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
23 deletions
+32
-23
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+7
-5
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+23
-16
go/zodb/zodb.go
go/zodb/zodb.go
+2
-2
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
26e8e3d3
...
...
@@ -606,12 +606,14 @@ mainloop:
//tracef("-> tid=%s δoidv=%v", it.Txnh.Tid, oidv)
select
{
case
<-
fs
.
down
:
return
nil
if
fs
.
watchq
!=
nil
{
select
{
case
<-
fs
.
down
:
return
nil
case
fs
.
watchq
<-
zodb
.
WatchEvent
{
it
.
Txnh
.
Tid
,
oidv
}
:
// ok
case
fs
.
watchq
<-
zodb
.
WatchEvent
{
it
.
Txnh
.
Tid
,
oidv
}
:
// ok
}
}
}
}
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
26e8e3d3
...
...
@@ -117,7 +117,11 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect objState) {
}
func
xfsopen
(
t
testing
.
TB
,
path
string
)
*
FileStorage
{
fs
,
err
:=
Open
(
context
.
Background
(),
path
)
return
xfsopenopt
(
t
,
path
,
&
zodb
.
DriverOptions
{
ReadOnly
:
true
})
}
func
xfsopenopt
(
t
testing
.
TB
,
path
string
,
opt
*
zodb
.
DriverOptions
)
*
FileStorage
{
fs
,
err
:=
Open
(
context
.
Background
(),
path
,
opt
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -125,7 +129,7 @@ func xfsopen(t testing.TB, path string) *FileStorage {
}
func
TestLoad
(
t
*
testing
.
T
)
{
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
// TODO open read-only
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
defer
exc
.
XRun
(
fs
.
Close
)
// current knowledge of what was "before" for an oid as we scan over
...
...
@@ -274,7 +278,7 @@ func testIterate(t *testing.T, fs *FileStorage, tidMin, tidMax zodb.Tid, expectv
}
func
TestIterate
(
t
*
testing
.
T
)
{
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
// TODO open ro
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
defer
exc
.
XRun
(
fs
.
Close
)
// all []tids in test database
...
...
@@ -310,7 +314,7 @@ func TestIterate(t *testing.T) {
}
func
BenchmarkIterate
(
b
*
testing
.
B
)
{
fs
:=
xfsopen
(
b
,
"testdata/1.fs"
)
// TODO open ro
fs
:=
xfsopen
(
b
,
"testdata/1.fs"
)
defer
exc
.
XRun
(
fs
.
Close
)
ctx
:=
context
.
Background
()
...
...
@@ -421,7 +425,8 @@ func TestWatch(t *testing.T) {
// force tfs creation & open tfs at go side
at
:=
xcommit
(
0
,
Object
{
0
,
"data0"
})
fs
:=
xfsopen
(
t
,
tfs
)
watchq
:=
make
(
chan
zodb
.
WatchEvent
)
fs
:=
xfsopenopt
(
t
,
tfs
,
&
zodb
.
DriverOptions
{
ReadOnly
:
true
,
WatchQ
:
watchq
})
ctx
:=
context
.
Background
()
checkLastTid
:=
func
(
lastOk
zodb
.
Tid
)
{
...
...
@@ -439,7 +444,7 @@ func TestWatch(t *testing.T) {
// commit -> check watcher observes what we committed.
//
// XXX python `import pkg_resources` takes ~
2
00ms.
// XXX python `import pkg_resources` takes ~
3
00ms.
// https://github.com/pypa/setuptools/issues/510
//
// Since pkg_resources are used everywhere (e.g. in zodburi to find all
...
...
@@ -452,13 +457,10 @@ func TestWatch(t *testing.T) {
Object
{
0
,
fmt
.
Sprintf
(
"data0.%d"
,
i
)},
Object
{
i
,
fmt
.
Sprintf
(
"data%d"
,
i
)})
tid
,
objv
,
err
:=
fs
.
Watch
(
ctx
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
e
:=
<-
watchq
// XXX err?
if
objvWant
:=
[]
zodb
.
Oid
{
0
,
i
};
!
(
tid
==
at
&&
reflect
.
DeepEqual
(
obj
v
,
objvWant
))
{
t
.
Fatalf
(
"watch:
\n
have: %s %s
\n
want: %s %s"
,
tid
,
obj
v
,
at
,
objvWant
)
if
objvWant
:=
[]
zodb
.
Oid
{
0
,
i
};
!
(
e
.
Tid
==
at
&&
reflect
.
DeepEqual
(
e
.
Change
v
,
objvWant
))
{
t
.
Fatalf
(
"watch:
\n
have: %s %s
\n
want: %s %s"
,
e
.
Tid
,
e
.
Change
v
,
at
,
objvWant
)
}
checkLastTid
(
at
)
...
...
@@ -469,8 +471,13 @@ func TestWatch(t *testing.T) {
t
.
Fatal
(
err
)
}
_
,
_
,
err
=
fs
.
Watch
(
ctx
)
if
e
,
eWant
:=
errors
.
Cause
(
err
),
os
.
ErrClosed
;
e
!=
eWant
{
t
.
Fatalf
(
"watch after close -> %v; want: cause %v"
,
err
,
eWant
)
}
e
:=
<-
watchq
_
=
e
_
=
errors
.
Cause
(
nil
)
// XXX e.Err == ErrClosed
//_, _, err = fs.Watch(ctx)
//if e, eWant := errors.Cause(err), os.ErrClosed; e != eWant {
// t.Fatalf("watch after close -> %v; want: cause %v", err, eWant)
//}
}
go/zodb/zodb.go
View file @
26e8e3d3
...
...
@@ -463,8 +463,8 @@ type Notifier interface {
// WatchEvent is one event describing observed database change.
type
WatchEvent
struct
{
Tid
Tid
Oidv
[]
Oid
Tid
Tid
Changev
[]
Oid
// XXX name
}
// Watcher allows to be notified of changes to database.
...
...
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