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
03e0cdef
Commit
03e0cdef
authored
Jul 06, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e9b424fc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
19 deletions
+33
-19
go/neo/client.go
go/neo/client.go
+4
-0
go/neo/neo_test.go
go/neo/neo_test.go
+1
-1
go/neo/neonet/connection.go
go/neo/neonet/connection.go
+8
-6
go/neo/proto/error.go
go/neo/proto/error.go
+18
-9
go/neo/storage.go
go/neo/storage.go
+2
-3
No files found.
go/neo/client.go
View file @
03e0cdef
...
@@ -388,6 +388,7 @@ func (c *Client) LastTid(ctx context.Context) (_ zodb.Tid, err error) {
...
@@ -388,6 +388,7 @@ func (c *Client) LastTid(ctx context.Context) (_ zodb.Tid, err error) {
reply
:=
proto
.
AnswerLastTransaction
{}
reply
:=
proto
.
AnswerLastTransaction
{}
err
=
mlink
.
Ask1
(
&
proto
.
LastTransaction
{},
&
reply
)
// XXX Ask += ctx
err
=
mlink
.
Ask1
(
&
proto
.
LastTransaction
{},
&
reply
)
// XXX Ask += ctx
if
err
!=
nil
{
if
err
!=
nil
{
// XXX ZODBErrDecode?
return
0
,
err
// XXX err ctx
return
0
,
err
// XXX err ctx
}
}
return
reply
.
Tid
,
nil
return
reply
.
Tid
,
nil
...
@@ -449,6 +450,9 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
...
@@ -449,6 +450,9 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
resp
:=
proto
.
AnswerObject
{}
resp
:=
proto
.
AnswerObject
{}
err
=
slink
.
Ask1
(
&
req
,
&
resp
)
err
=
slink
.
Ask1
(
&
req
,
&
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
if
e
,
ok
:=
err
.
(
*
proto
.
Error
);
ok
{
err
=
proto
.
ZODBErrDecode
(
e
)
}
return
nil
,
0
,
err
// XXX err context
return
nil
,
0
,
err
// XXX err context
}
}
...
...
go/neo/neo_test.go
View file @
03e0cdef
...
@@ -467,7 +467,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
...
@@ -467,7 +467,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
return
M
.
Run
(
ctx
)
return
M
.
Run
(
ctx
)
})
})
// determing M serving address XXX better with M api
// determin
in
g M serving address XXX better with M api
ev
:=
cG
.
Recv
()
ev
:=
cG
.
Recv
()
mnode
,
ok
:=
ev
.
Event
.
(
*
eventNodeTab
)
mnode
,
ok
:=
ev
.
Event
.
(
*
eventNodeTab
)
if
!
ok
{
if
!
ok
{
...
...
go/neo/neonet/connection.go
View file @
03e0cdef
...
@@ -1411,12 +1411,14 @@ func (c *Conn) _Expect(pkt *pktBuf, msgv ...proto.Msg) (int, error) {
...
@@ -1411,12 +1411,14 @@ func (c *Conn) _Expect(pkt *pktBuf, msgv ...proto.Msg) (int, error) {
return
-
1
,
c
.
err
(
"recv"
,
fmt
.
Errorf
(
"unexpected message: %v"
,
msgType
))
return
-
1
,
c
.
err
(
"recv"
,
fmt
.
Errorf
(
"unexpected message: %v"
,
msgType
))
}
}
// Ask sends request and receives response.
// Ask sends request and receives
a
response.
//
//
// It expects response to be e
xactly of resp type and errors otherwise.
// It expects response to be e
ither of resp type or proto.Error:
//
//
// XXX clarify error semantic (when Error is decoded)
// If resp-type message is received, it is decoded inplace and nil is returned.
// XXX do the same as Expect wrt respv ?
// If proto.Error message is received, it is returned as error.
//
// Otherwise returned error describes the problem.
func
(
c
*
Conn
)
Ask
(
req
proto
.
Msg
,
resp
proto
.
Msg
)
error
{
func
(
c
*
Conn
)
Ask
(
req
proto
.
Msg
,
resp
proto
.
Msg
)
error
{
err
:=
c
.
Send
(
req
)
err
:=
c
.
Send
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -1429,7 +1431,7 @@ func (c *Conn) Ask(req proto.Msg, resp proto.Msg) error {
...
@@ -1429,7 +1431,7 @@ func (c *Conn) Ask(req proto.Msg, resp proto.Msg) error {
case
0
:
case
0
:
return
nil
return
nil
case
1
:
case
1
:
return
proto
.
ErrDecode
(
nerr
)
return
nerr
}
}
return
err
return
err
...
@@ -1566,7 +1568,7 @@ func (conn *Conn) _Ask1(req proto.Msg, resp proto.Msg) error {
...
@@ -1566,7 +1568,7 @@ func (conn *Conn) _Ask1(req proto.Msg, resp proto.Msg) error {
case
0
:
case
0
:
return
nil
return
nil
case
1
:
case
1
:
return
proto
.
ErrDecode
(
nerr
)
return
nerr
}
}
return
err
return
err
...
...
go/neo/proto/error.go
View file @
03e0cdef
...
@@ -26,15 +26,22 @@ import (
...
@@ -26,15 +26,22 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
)
)
// XXX name -> zodbErrEncode, zodbErrDecode ?
// XXX should be not in proto/ ?
// XXX should be not in proto/ ?
// ErrEncode translates an error into Error packet.
// ZODBErrEncode translates a ZODB error into Error packet.
// XXX more text describing relation with zodb errors
//
func
ErrEncode
(
err
error
)
*
Error
{
// ZODB errors (e.g. zodb.NoDataError) are specifically encoded, so that on
// receiver side they can be recreated with ErrDecode. If err is zodb.OpError,
// only its inner cause is encoded.
//
// If err is not ZODB error -> it is incoded as "503".
func
ZODBErrEncode
(
err
error
)
*
Error
{
e
,
ok
:=
err
.
(
*
zodb
.
OpError
)
if
ok
{
err
=
e
.
Err
}
switch
err
:=
err
.
(
type
)
{
switch
err
:=
err
.
(
type
)
{
case
*
Error
:
return
err
case
*
zodb
.
NoDataError
:
case
*
zodb
.
NoDataError
:
// XXX abusing message for oid, deletedAt
// XXX abusing message for oid, deletedAt
return
&
Error
{
return
&
Error
{
...
@@ -52,9 +59,11 @@ func ErrEncode(err error) *Error {
...
@@ -52,9 +59,11 @@ func ErrEncode(err error) *Error {
}
}
// ErrDecode decodes error from Error packet.
// ZODBErrDecode decodes an error from Error packet.
// XXX more text describing relation with zodb errors
//
func
ErrDecode
(
e
*
Error
)
error
{
// If it was ZODB error - it is decoded from the packet and returned.
// Otherwise e is returned as is.
func
ZODBErrDecode
(
e
*
Error
)
error
{
switch
e
.
Code
{
switch
e
.
Code
{
case
OID_NOT_FOUND
:
case
OID_NOT_FOUND
:
// XXX abusing message for oid, deletedAt
// XXX abusing message for oid, deletedAt
...
...
go/neo/storage.go
View file @
03e0cdef
...
@@ -542,8 +542,7 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot
...
@@ -542,8 +542,7 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot
obj
,
err
:=
stor
.
back
.
Load
(
ctx
,
xid
)
obj
,
err
:=
stor
.
back
.
Load
(
ctx
,
xid
)
if
err
!=
nil
{
if
err
!=
nil
{
// translate err to NEO protocol error codes
// translate err to NEO protocol error codes
e
:=
err
.
(
*
zodb
.
OpError
)
// XXX move this to ErrEncode?
return
proto
.
ZODBErrEncode
(
err
)
return
proto
.
ErrEncode
(
e
.
Err
)
}
}
// compatibility with py side:
// compatibility with py side:
...
@@ -562,7 +561,7 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot
...
@@ -562,7 +561,7 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot
case
*
proto
.
LastTransaction
:
case
*
proto
.
LastTransaction
:
lastTid
,
err
:=
stor
.
back
.
LastTid
(
ctx
)
lastTid
,
err
:=
stor
.
back
.
LastTid
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
proto
.
ErrEncode
(
err
)
return
proto
.
ZODB
ErrEncode
(
err
)
}
}
return
&
proto
.
AnswerLastTransaction
{
lastTid
}
return
&
proto
.
AnswerLastTransaction
{
lastTid
}
...
...
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