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
f9f4b93d
Commit
f9f4b93d
authored
Dec 26, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a4be5d2f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
18 deletions
+20
-18
go/zodb/open.go
go/zodb/open.go
+13
-11
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+2
-2
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+1
-1
go/zodb/zodb.go
go/zodb/zodb.go
+4
-4
No files found.
go/zodb/open.go
View file @
f9f4b93d
...
@@ -46,7 +46,7 @@ type DriverOptions struct {
...
@@ -46,7 +46,7 @@ type DriverOptions struct {
// it can get out of sync with the on-disk database file.
// it can get out of sync with the on-disk database file.
//
//
// The storage driver closes !nil Watchq when the driver is closed.
// The storage driver closes !nil Watchq when the driver is closed.
Watchq
chan
<-
Watch
Event
Watchq
chan
<-
Commit
Event
}
}
// DriverOpener is a function to open a storage driver.
// DriverOpener is a function to open a storage driver.
...
@@ -91,7 +91,7 @@ func OpenStorage(ctx context.Context, storageURL string, opt *OpenOptions) (ISto
...
@@ -91,7 +91,7 @@ func OpenStorage(ctx context.Context, storageURL string, opt *OpenOptions) (ISto
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
}
}
drvWatchq
:=
make
(
chan
Watch
Event
)
drvWatchq
:=
make
(
chan
Commit
Event
)
drvOpt
:=
&
DriverOptions
{
drvOpt
:=
&
DriverOptions
{
ReadOnly
:
opt
.
ReadOnly
,
ReadOnly
:
opt
.
ReadOnly
,
Watchq
:
drvWatchq
,
Watchq
:
drvWatchq
,
...
@@ -115,7 +115,7 @@ func OpenStorage(ctx context.Context, storageURL string, opt *OpenOptions) (ISto
...
@@ -115,7 +115,7 @@ func OpenStorage(ctx context.Context, storageURL string, opt *OpenOptions) (ISto
drvWatchq
:
drvWatchq
,
drvWatchq
:
drvWatchq
,
watchReq
:
make
(
chan
watchRequest
),
watchReq
:
make
(
chan
watchRequest
),
watchTab
:
make
(
map
[
chan
Watch
Event
]
struct
{}),
watchTab
:
make
(
map
[
chan
Commit
Event
]
struct
{}),
},
nil
},
nil
}
}
...
@@ -131,9 +131,9 @@ type storage struct {
...
@@ -131,9 +131,9 @@ type storage struct {
l1cache
*
Cache
// can be =nil, if opened with NoCache
l1cache
*
Cache
// can be =nil, if opened with NoCache
// watcher
// watcher
drvWatchq
chan
Watch
Event
// watchq passed to driver
drvWatchq
chan
Commit
Event
// watchq passed to driver
watchReq
chan
watchRequest
// {Add,Del}Watch requests go here
watchReq
chan
watchRequest
// {Add,Del}Watch requests go here
watchTab
map
[
chan
Watch
Event
]
struct
{}
// registered watchers
watchTab
map
[
chan
Commit
Event
]
struct
{}
// registered watchers
}
}
// loading goes through cache - this way prefetching can work
// loading goes through cache - this way prefetching can work
...
@@ -162,9 +162,9 @@ func (s *storage) Prefetch(ctx context.Context, xid Xid) {
...
@@ -162,9 +162,9 @@ func (s *storage) Prefetch(ctx context.Context, xid Xid) {
// watchRequest represents request to add/del a watch.
// watchRequest represents request to add/del a watch.
type
watchRequest
struct
{
type
watchRequest
struct
{
op
watchOp
// add or del
op
watchOp
// add or del
ack
chan
struct
{}
// when request processed
ack
chan
struct
{}
// when request processed
watchq
chan
Watch
Event
// {Add,Del}Watch argument
watchq
chan
Commit
Event
// {Add,Del}Watch argument
}
}
type
watchOp
int
type
watchOp
int
...
@@ -204,14 +204,16 @@ func (s *storage) watcher() {
...
@@ -204,14 +204,16 @@ func (s *storage) watcher() {
}
}
}
}
func
(
s
*
storage
)
AddWatch
(
watchq
chan
WatchEvent
)
{
// AddWatch implements Watcher.
func
(
s
*
storage
)
AddWatch
(
watchq
chan
CommitEvent
)
{
// XXX when already Closed?
// XXX when already Closed?
ack
:=
make
(
chan
struct
{})
ack
:=
make
(
chan
struct
{})
s
.
watchReq
<-
watchRequest
{
addWatch
,
ack
,
watchq
}
s
.
watchReq
<-
watchRequest
{
addWatch
,
ack
,
watchq
}
<-
ack
<-
ack
}
}
func
(
s
*
storage
)
DelWatch
(
watchq
chan
WatchEvent
)
{
// DelWatch implements Watcher.
func
(
s
*
storage
)
DelWatch
(
watchq
chan
CommitEvent
)
{
// XXX when already Closed?
// XXX when already Closed?
ack
:=
make
(
chan
struct
{})
ack
:=
make
(
chan
struct
{})
s
.
watchReq
<-
watchRequest
{
delWatch
,
ack
,
watchq
}
s
.
watchReq
<-
watchRequest
{
delWatch
,
ack
,
watchq
}
...
...
go/zodb/storage/fs1/filestorage.go
View file @
f9f4b93d
...
@@ -99,7 +99,7 @@ type FileStorage struct {
...
@@ -99,7 +99,7 @@ type FileStorage struct {
downErr
error
// !nil when the storage is no longer operational
downErr
error
// !nil when the storage is no longer operational
// driver client <- watcher: database commits.
// driver client <- watcher: database commits.
watchq
chan
<-
zodb
.
Watch
Event
watchq
chan
<-
zodb
.
Commit
Event
down
chan
struct
{}
// ready when storage is no longer operational
down
chan
struct
{}
// ready when storage is no longer operational
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
...
@@ -668,7 +668,7 @@ mainloop:
...
@@ -668,7 +668,7 @@ mainloop:
case
<-
fs
.
down
:
case
<-
fs
.
down
:
return
nil
return
nil
case
fs
.
watchq
<-
zodb
.
Watch
Event
{
it
.
Txnh
.
Tid
,
oidv
}
:
case
fs
.
watchq
<-
zodb
.
Commit
Event
{
it
.
Txnh
.
Tid
,
oidv
}
:
// ok
// ok
}
}
}
}
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
f9f4b93d
...
@@ -410,7 +410,7 @@ func TestWatch(t *testing.T) {
...
@@ -410,7 +410,7 @@ func TestWatch(t *testing.T) {
// force tfs creation & open tfs at go side
// force tfs creation & open tfs at go side
at
:=
xcommit
(
0
,
Object
{
0
,
"data0"
})
at
:=
xcommit
(
0
,
Object
{
0
,
"data0"
})
watchq
:=
make
(
chan
zodb
.
Watch
Event
)
watchq
:=
make
(
chan
zodb
.
Commit
Event
)
fs
:=
xfsopenopt
(
t
,
tfs
,
&
zodb
.
DriverOptions
{
ReadOnly
:
true
,
Watchq
:
watchq
})
fs
:=
xfsopenopt
(
t
,
tfs
,
&
zodb
.
DriverOptions
{
ReadOnly
:
true
,
Watchq
:
watchq
})
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
...
go/zodb/zodb.go
View file @
f9f4b93d
...
@@ -429,8 +429,8 @@ type Committer interface {
...
@@ -429,8 +429,8 @@ type Committer interface {
}
}
//
WatchEvent is one event describing observed database change
.
//
CommitEvent is event describing one observed database commit
.
type
Watch
Event
struct
{
type
Commit
Event
struct
{
Tid
Tid
Tid
Tid
Changev
[]
Oid
// XXX name
Changev
[]
Oid
// XXX name
}
}
...
@@ -447,14 +447,14 @@ type Watcher interface {
...
@@ -447,14 +447,14 @@ type Watcher interface {
// Once registered, watchq must be read. Not doing so will stuck whole storage.
// Once registered, watchq must be read. Not doing so will stuck whole storage.
//
//
// Multiple AddWatch calls with the same watchq register watchq only once.
// Multiple AddWatch calls with the same watchq register watchq only once.
AddWatch
(
watchq
chan
Watch
Event
)
AddWatch
(
watchq
chan
Commit
Event
)
// DelWatch unregisters watchq to be notified of database changes.
// DelWatch unregisters watchq to be notified of database changes.
//
//
// After DelWatch call completes, no new events will be sent to watchq.
// After DelWatch call completes, no new events will be sent to watchq.
//
//
// DelWatch is noop if watchq was not registered.
// DelWatch is noop if watchq was not registered.
DelWatch
(
watchq
chan
Watch
Event
)
DelWatch
(
watchq
chan
Commit
Event
)
}
}
...
...
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