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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
8b51a7b8
Commit
8b51a7b8
authored
Jul 09, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
96da2b58
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
go/zodb/storage/zeo/zeo.go
go/zodb/storage/zeo/zeo.go
+10
-14
go/zodb/storage/zeo/zrpc.go
go/zodb/storage/zeo/zrpc.go
+17
-2
No files found.
go/zodb/storage/zeo/zeo.go
View file @
8b51a7b8
...
@@ -385,19 +385,7 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
...
@@ -385,19 +385,7 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"TODO write mode not implemented"
)
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"TODO write mode not implemented"
)
}
}
z
:=
&
zeo
{
watchq
:
opt
.
Watchq
,
url
:
url
}
zl
,
err
:=
dialZLink
(
ctx
,
net
,
addr
)
//zl, err := dialZLink(ctx, net, addr) // XXX + methodTable {invalidateTransaction tid, oidv} -> ...
zl
,
err
:=
dialZLink
(
ctx
,
net
,
addr
,
/*
// notifyTab
map[string]func(interface{})error {
"invalidateTransaction": z.invalidateTransaction,
},
// serveTab
nil,
*/
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
zodb
.
InvalidTid
,
err
return
nil
,
zodb
.
InvalidTid
,
err
}
}
...
@@ -409,7 +397,15 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
...
@@ -409,7 +397,15 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
}()
}()
z
.
link
=
zl
z
:=
&
zeo
{
link
:
zl
,
watchq
:
opt
.
Watchq
,
url
:
url
}
zl
.
StartServe
(
// notifyTab
map
[
string
]
func
(
interface
{})
error
{
"invalidateTransaction"
:
z
.
invalidateTransaction
,
},
// serveTab
nil
,
)
rpc
:=
z
.
rpc
(
"register"
)
rpc
:=
z
.
rpc
(
"register"
)
xlastTid
,
err
:=
rpc
.
call
(
ctx
,
storageID
,
opt
.
ReadOnly
)
xlastTid
,
err
:=
rpc
.
call
(
ctx
,
storageID
,
opt
.
ReadOnly
)
...
...
go/zodb/storage/zeo/zrpc.go
View file @
8b51a7b8
...
@@ -50,6 +50,7 @@ var protoVersions = []string{
...
@@ -50,6 +50,7 @@ var protoVersions = []string{
// zLink provides service to make and receive RPC requests.
// zLink provides service to make and receive RPC requests.
//
//
// create zLink via dialZLink or handshake.
// create zLink via dialZLink or handshake.
// once link is created .StartServe must be called on it.
type
zLink
struct
{
type
zLink
struct
{
link
net
.
Conn
// underlying network
link
net
.
Conn
// underlying network
rxbuf
rbuf
.
RingBuf
// buffer for reading from link
rxbuf
rbuf
.
RingBuf
// buffer for reading from link
...
@@ -60,11 +61,12 @@ type zLink struct {
...
@@ -60,11 +61,12 @@ type zLink struct {
callID
int64
// ID for next call; incremented at every call
callID
int64
// ID for next call; incremented at every call
// methods peer can invoke
// methods peer can invoke
serveReady
chan
struct
{}
// ready after serveTab and notifyTab are initialized by user
// methods are served in parallel
// methods are served in parallel
serveTab
map
[
string
]
func
(
context
.
Context
,
interface
{})
interface
{}
serveTab
map
[
string
]
func
(
context
.
Context
,
interface
{})
interface
{}
// notifications peer can send
// notifications peer can send
// notifications are invoked in order
// notifications are invoked in order
notifyTab
map
[
string
]
func
(
interface
{})
notifyTab
map
[
string
]
func
(
interface
{})
error
serveWg
sync
.
WaitGroup
// for serveRecv and serveTab spawned from it
serveWg
sync
.
WaitGroup
// for serveRecv and serveTab spawned from it
serveCtx
context
.
Context
// serveTab handlers are called with this ctx
serveCtx
context
.
Context
// serveTab handlers are called with this ctx
...
@@ -85,6 +87,15 @@ func (zl *zLink) start() {
...
@@ -85,6 +87,15 @@ func (zl *zLink) start() {
go
zl
.
serveRecv
()
go
zl
.
serveRecv
()
}
}
func
(
zl
*
zLink
)
StartServe
(
notifyTab
map
[
string
]
func
(
interface
{})
error
,
serveTab
map
[
string
]
func
(
context
.
Context
,
interface
{})
interface
{},
)
{
zl
.
serveTab
=
serveTab
zl
.
notifyTab
=
notifyTab
close
(
zl
.
serveReady
)
}
var
errLinkClosed
=
errors
.
New
(
"zlink is closed"
)
var
errLinkClosed
=
errors
.
New
(
"zlink is closed"
)
// shutdown shuts zlink down and sets error (XXX) which
// shutdown shuts zlink down and sets error (XXX) which
...
@@ -166,6 +177,10 @@ func (zl *zLink) serveRecv1(pkb *pktBuf) error {
...
@@ -166,6 +177,10 @@ func (zl *zLink) serveRecv1(pkb *pktBuf) error {
return
nil
return
nil
}
}
// message is notification or call
// wait until user called StartServe on us
<-
zl
.
serveReady
// message is notification
// message is notification
if
m
.
flags
&
msgAsync
!=
0
{
if
m
.
flags
&
msgAsync
!=
0
{
// notifications go in-order
// notifications go in-order
...
@@ -455,7 +470,7 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
...
@@ -455,7 +470,7 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
// create raw zlink since we need to do the handshake as ZEO message exchange,
// create raw zlink since we need to do the handshake as ZEO message exchange,
// but don't start serve goroutines yet.
// but don't start serve goroutines yet.
zl
:=
&
zLink
{
link
:
conn
}
zl
:=
&
zLink
{
link
:
conn
,
serveReady
:
make
(
chan
struct
{})
}
// ready when/if handshake tx/rx exchange succeeds
// ready when/if handshake tx/rx exchange succeeds
hok
:=
make
(
chan
struct
{})
hok
:=
make
(
chan
struct
{})
...
...
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