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
44f5a726
Commit
44f5a726
authored
Dec 18, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ffef2a72
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
31 deletions
+54
-31
go/neo/client.go
go/neo/client.go
+3
-1
go/zodb/open.go
go/zodb/open.go
+20
-2
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+13
-13
go/zodb/storage/fs1/url.go
go/zodb/storage/fs1/url.go
+2
-9
go/zodb/storage/zeo/zeo.go
go/zodb/storage/zeo/zeo.go
+3
-1
go/zodb/zodb.go
go/zodb/zodb.go
+13
-5
No files found.
go/neo/client.go
View file @
44f5a726
...
...
@@ -494,7 +494,7 @@ func (c *Client) Watch(ctx context.Context) (zodb.Tid, []zodb.Oid, error) {
// ---- ZODB open/url support ----
func
openClientByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
zodb
.
Open
Options
)
(
zodb
.
IStorageDriver
,
error
)
{
func
openClientByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
zodb
.
Driver
Options
)
(
zodb
.
IStorageDriver
,
error
)
{
// neo://name@master1,master2,...,masterN?options
if
u
.
User
==
nil
{
...
...
@@ -507,6 +507,8 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.OpenOptions) (zo
return
nil
,
fmt
.
Errorf
(
"neo: %s: TODO write mode not implemented"
,
u
)
}
// XXX handle opt.WatchQ
// XXX check/use other url fields
net
:=
xnet
.
NetPlain
(
"tcp"
)
// TODO + TLS; not only "tcp" ?
...
...
go/zodb/open.go
View file @
44f5a726
...
...
@@ -35,8 +35,21 @@ type OpenOptions struct {
NoCache
bool
// don't use cache for read/write operations; prefetch will be noop
}
// DriverOptions describes options for DriverOpener
type
DriverOptions
struct
{
ReadOnly
bool
// whether to open storage as read-only
// Channel where watched storage events have to be delivered.
// WatchQ can be nil to ignore such events. However if WatchQ != nil, the events
// have to be consumed or else the storage driver will misbehave - e.g.
// it can get out of sync with the on-disk database file.
//
// XXX the channel will be closed after ... ?
WatchQ
chan
WatchEvent
}
// DriverOpener is a function to open a storage driver.
type
DriverOpener
func
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
Open
Options
)
(
IStorageDriver
,
error
)
type
DriverOpener
func
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
Driver
Options
)
(
IStorageDriver
,
error
)
// {} scheme -> DriverOpener
var
driverRegistry
=
map
[
string
]
DriverOpener
{}
...
...
@@ -77,7 +90,12 @@ func OpenStorage(ctx context.Context, storageURL string, opt *OpenOptions) (ISto
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
}
storDriver
,
err
:=
opener
(
ctx
,
u
,
opt
)
drvOpt
:=
&
DriverOptions
{
ReadOnly
:
opt
.
ReadOnly
,
// TODO watchq
}
storDriver
,
err
:=
opener
(
ctx
,
u
,
drvOpt
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
go/zodb/storage/fs1/filestorage.go
View file @
44f5a726
...
...
@@ -97,7 +97,7 @@ type FileStorage struct {
txnhMax
TxnHeader
// (both with .Len=0 & .Tid=0 if database is empty)
// driver client <- watcher: data file updates.
watchq
chan
w
atchEvent
watchq
chan
zodb
.
W
atchEvent
down
chan
struct
{}
// ready when FileStorage is no longer operational
downOnce
sync
.
Once
...
...
@@ -513,7 +513,7 @@ mainloop:
return
err
}
fsize
:=
fi
.
Size
()
tracef
(
"toppos: %d
\t
fsize: %d
\n
"
,
idx
.
TopPos
,
fsize
)
//
tracef("toppos: %d\tfsize: %d\n", idx.TopPos, fsize)
switch
{
case
fsize
==
idx
.
TopPos
:
continue
// same as before
...
...
@@ -562,7 +562,7 @@ mainloop:
// read ok - reset t₀(partial)
t0partial
=
time
.
Time
{}
tracef
(
"@%d tid=%s st=%q"
,
it
.
Txnh
.
Pos
,
it
.
Txnh
.
Tid
,
it
.
Txnh
.
Status
)
//
tracef("@%d tid=%s st=%q", it.Txnh.Pos, it.Txnh.Tid, it.Txnh.Status)
// XXX dup wrt Index.Update
...
...
@@ -604,25 +604,20 @@ mainloop:
}
fs
.
mu
.
Unlock
()
tracef
(
"-> tid=%s δoidv=%v"
,
it
.
Txnh
.
Tid
,
oidv
)
//
tracef("-> tid=%s δoidv=%v", it.Txnh.Tid, oidv)
select
{
case
<-
fs
.
down
:
return
nil
case
fs
.
watchq
<-
w
atchEvent
{
it
.
Txnh
.
Tid
,
oidv
}
:
case
fs
.
watchq
<-
zodb
.
W
atchEvent
{
it
.
Txnh
.
Tid
,
oidv
}
:
// ok
}
}
}
}
// watchEvent is one event from watch to Watch
type
watchEvent
struct
{
tid
zodb
.
Tid
oidv
[]
zodb
.
Oid
}
/*
// XXX doc
func (fs *FileStorage) Watch(ctx context.Context) (_ zodb.Tid, _ []zodb.Oid, err error) {
defer xerr.Contextf(&err, "%s: watch", fs.file.Name())
...
...
@@ -638,6 +633,7 @@ func (fs *FileStorage) Watch(ctx context.Context) (_ zodb.Tid, _ []zodb.Oid, err
return w.tid, w.oidv, nil
}
}
*/
// --- open + rebuild index ---
...
...
@@ -662,9 +658,13 @@ func (fs *FileStorage) Close() error {
// Open opens FileStorage @path.
//
// TODO read-write support
func
Open
(
ctx
context
.
Context
,
path
string
)
(
_
*
FileStorage
,
err
error
)
{
func
Open
(
ctx
context
.
Context
,
path
string
,
opt
*
zodb
.
DriverOptions
)
(
_
*
FileStorage
,
err
error
)
{
if
!
opt
.
ReadOnly
{
return
nil
,
fmt
.
Errorf
(
"fs1: %s: TODO write mode not implemented"
,
path
)
}
fs
:=
&
FileStorage
{
watchq
:
make
(
chan
watchEvent
)
,
watchq
:
opt
.
WatchQ
,
down
:
make
(
chan
struct
{}),
}
...
...
go/zodb/storage/fs1/url.go
View file @
44f5a726
...
...
@@ -22,24 +22,17 @@ package fs1
import
(
"context"
"fmt"
"net/url"
"lab.nexedi.com/kirr/neo/go/zodb"
)
func
openByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
zodb
.
Open
Options
)
(
zodb
.
IStorageDriver
,
error
)
{
func
openByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
zodb
.
Driver
Options
)
(
zodb
.
IStorageDriver
,
error
)
{
// TODO handle query
// XXX u.Path is not always raw path - recheck and fix
path
:=
u
.
Host
+
u
.
Path
// XXX readonly stub
// XXX place = ?
if
!
opt
.
ReadOnly
{
return
nil
,
fmt
.
Errorf
(
"fs1: %s: TODO write mode not implemented"
,
path
)
}
fs
,
err
:=
Open
(
ctx
,
path
)
fs
,
err
:=
Open
(
ctx
,
path
,
opt
)
return
fs
,
err
}
...
...
go/zodb/storage/zeo/zeo.go
View file @
44f5a726
...
...
@@ -283,7 +283,7 @@ func (r rpc) ereplyf(format string, argv ...interface{}) *errorUnexpectedReply {
// ---- open ----
func
openByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
zodb
.
Open
Options
)
(
_
zodb
.
IStorageDriver
,
err
error
)
{
func
openByURL
(
ctx
context
.
Context
,
u
*
url
.
URL
,
opt
*
zodb
.
Driver
Options
)
(
_
zodb
.
IStorageDriver
,
err
error
)
{
url
:=
u
.
String
()
defer
xerr
.
Contextf
(
&
err
,
"open %s:"
,
url
)
...
...
@@ -310,6 +310,8 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.OpenOptions) (_ zodb.I
return
nil
,
fmt
.
Errorf
(
"TODO write mode not implemented"
)
}
// XXX handle opt.WatchQ
zl
,
err
:=
dialZLink
(
ctx
,
net
,
addr
)
// XXX + methodTable
if
err
!=
nil
{
return
nil
,
err
...
...
go/zodb/zodb.go
View file @
44f5a726
...
...
@@ -352,6 +352,8 @@ type Prefetcher interface {
}
// IStorageDriver is the raw interface provided by ZODB storage drivers.
//
// A storage driver is created by DriverOpener
type
IStorageDriver
interface
{
// URL returns URL of how the storage was opened
URL
()
string
...
...
@@ -366,21 +368,21 @@ type IStorageDriver interface {
Loader
Iterator
/*
Watcher
/*
// Notifier returns storage driver notifier.
//
// The notifier represents invalidation channel (notify about changes
// made to DB
not by us from outside
). XXX
// made to DB). XXX
//
// To simplify drivers, there must be only 1 logical user of
// storage-driver level notifier interface. Contrary IStorage allows
// for several users of notification channel. XXX ok?
//
// XXX -> nil, if driver does not support notifications?
// XXX or always support them, even with FileStorage (inotify)?
//Notifier() Notifier
// XXX Watch() -> Watcher
// XXX SetWatcher(watchq) SetWatchSink() ? XXX -> ctor ?
*/
}
...
...
@@ -457,6 +459,12 @@ type Notifier interface {
}
*/
// WatchEvent is one event describing observed database change.
type
WatchEvent
struct
{
Tid
Tid
Oidv
[]
Oid
}
// Watcher allows to be notified of changes to database.
type
Watcher
interface
{
...
...
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