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
42ff83d9
Commit
42ff83d9
authored
Feb 19, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f8859a39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
go/zodb/open.go
go/zodb/open.go
+2
-0
go/zodb/zodbtools/watch_test.go
go/zodb/zodbtools/watch_test.go
+22
-9
No files found.
go/zodb/open.go
View file @
42ff83d9
...
...
@@ -195,6 +195,8 @@ const (
delWatch
watchOp
=
1
)
// watcher dispatches events from driver to subscribers and serves
// {Add,Del}Watch requests.
func
(
s
*
storage
)
watcher
()
{
for
{
select
{
...
...
go/zodb/zodbtools/watch_test.go
View file @
42ff83d9
...
...
@@ -54,22 +54,24 @@ func TestWatch(t *testing.T) {
t
.
Fatal
(
err
)
}
}
obj
:=
func
(
oid
zodb
.
Oid
,
data
string
)
xtesting
.
ZRawObject
{
return
xtesting
.
ZRawObject
{
oid
,
[]
byte
(
data
)}
}
xcommit
(
obj
(
0
,
"data0"
))
xcommit
(
xtesting
.
ZRawObject
{
0
,
[]
byte
(
"data0"
)})
// open tfs at go side
stor
,
err
:=
zodb
.
OpenStorage
(
context
.
Background
(),
tfs
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
});
X
(
err
)
// spawn plain and verbose watchers
ctx0
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx0
)
// gowatch spawns Watch(verbose) and returns expect
(line
) func that is
// connected to Watch output.
// gowatch spawns Watch(verbose) and returns expect
f(
) func that is
// connected to
verify
Watch output.
gowatch
:=
func
(
verbose
bool
)
/*expectf*/
func
(
format
string
,
argv
...
interface
{})
{
pr
,
pw
:=
io
.
Pipe
()
wg
.
Go
(
func
()
error
{
stor
,
err
:=
zodb
.
OpenStorage
(
ctx
,
tfs
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
if
err
!=
nil
{
return
err
}
return
Watch
(
ctx
,
stor
,
pw
,
verbose
)
})
...
...
@@ -92,17 +94,20 @@ func TestWatch(t *testing.T) {
pexpect
:=
gowatch
(
false
)
vexpect
:=
gowatch
(
true
)
// initial header
pexpect
(
"# at %s"
,
at
)
vexpect
(
"# at %s"
,
at
)
xcommit
(
xtesting
.
ZRawObject
{
0
,
[]
byte
(
"data01"
)})
// commit -> output
xcommit
(
obj
(
0
,
"data01"
))
pexpect
(
"txn %s"
,
at
)
vexpect
(
"txn %s"
,
at
)
vexpect
(
"obj 0000000000000000"
)
vexpect
(
""
)
xcommit
(
xtesting
.
ZRawObject
{
1
,
[]
byte
(
"data1"
)},
xtesting
.
ZRawObject
{
2
,
[]
byte
(
"data2"
)})
// commit -> output
xcommit
(
obj
(
1
,
"data1"
),
obj
(
2
,
"data2"
))
pexpect
(
"txn %s"
,
at
)
vexpect
(
"txn %s"
,
at
)
...
...
@@ -117,4 +122,12 @@ func TestWatch(t *testing.T) {
if
ecause
!=
context
.
Canceled
{
t
.
Fatalf
(
"finished: err: expected 'canceled' cause; got %q"
,
err
)
}
// commit after watchers canceled - storage must be alive
// (this verifies DelWatch)
// XXX move -> zodb tests
xcommit
(
obj
(
3
,
"data3"
))
println
(
"AAA"
)
stor
.
DelWatch
(
nil
)
println
(
"BBB"
)
}
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