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
2933330b
Commit
2933330b
authored
Jul 13, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1f7deac2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
69 deletions
+51
-69
go/zodb/storage/zeo/proto.go
go/zodb/storage/zeo/proto.go
+50
-68
go/zodb/storage/zeo/zeo.go
go/zodb/storage/zeo/zeo.go
+1
-1
No files found.
go/zodb/storage/zeo/proto.go
View file @
2933330b
...
...
@@ -48,7 +48,7 @@ type msg struct {
msgid
int64
flags
msgFlags
method
string
arg
interface
{}
// can be e.g.
tuple
(arg1, arg2, ...)
arg
interface
{}
// can be e.g. (arg1, arg2, ...)
}
type
msgFlags
int64
...
...
@@ -85,15 +85,6 @@ func (e encoding) pktDecode(pkb *pktBuf) (msg, error) {
func
pktEncodeZ
(
m
msg
)
*
pktBuf
{
pkb
:=
allocPkb
()
p
:=
pickle
.
NewEncoder
(
pkb
)
/*
// tuple -> pickle.Tuple XXX needed? (should be produced by enc.Tuple)
arg := m.arg
tup, ok := arg.(tuple)
if ok {
arg = pickle.Tuple(tup)
}
*/
err
:=
p
.
Encode
(
pickle
.
Tuple
{
m
.
msgid
,
m
.
flags
,
m
.
method
,
m
.
arg
})
if
err
!=
nil
{
panic
(
err
)
// all our types are expected to be supported by pickle
...
...
@@ -113,16 +104,6 @@ func pktEncodeM(m msg) *pktBuf {
// arg
// it is interface{} - use shamaton/msgpack since msgp does not handle
// arbitrary interfaces well.
/*
// XXX shamaton/msgpack encodes tuple(nil) as nil, not empty tuple
// XXX move to zLink.Call?
arg := m.arg
tup, ok := arg.(tuple)
if ok && tup == nil {
arg = tuple{}
}
dataArg, err := msgpack.Encode(arg)
*/
dataArg
,
err
:=
msgpack
.
Encode
(
m
.
arg
)
if
err
!=
nil
{
panic
(
err
)
// all our types are expected to be supported by msgpack
...
...
@@ -275,6 +256,55 @@ func derrf(format string, argv ...interface{}) error {
// ---- retrieve/put objects from/into msg.arg ----
// tuple represents py tuple.
type
tuple
[]
interface
{}
// Tuple converts t into corresponding object appropriate for encoding e.
func
(
e
encoding
)
Tuple
(
t
tuple
)
interface
{}
{
switch
e
{
default
:
panic
(
"bug"
)
case
'Z'
:
// pickle: -> pickle.Tuple
return
pickle
.
Tuple
(
t
)
case
'M'
:
// msgpack: -> leave as tuple
// However shamaton/msgpack encodes tuple(nil) as nil, not empty tuple
// so nil -> tuple{}
if
t
==
nil
{
t
=
tuple
{}
}
return
t
}
}
// asTuple tries to retrieve tuple from corresponding object decoded via encoding e.
func
(
e
encoding
)
asTuple
(
xt
interface
{})
(
tuple
,
bool
)
{
switch
e
{
default
:
panic
(
"bug"
)
case
'Z'
:
// pickle: tuples are represented by pickle.Tuple; lists as []interface{}
switch
t
:=
xt
.
(
type
)
{
case
pickle
.
Tuple
:
return
tuple
(
t
),
true
case
[]
interface
{}
:
return
tuple
(
t
),
true
default
:
return
tuple
(
nil
),
false
}
case
'M'
:
// msgpack: tuples/lists are encoded as arrays; decoded as []interface{}
t
,
ok
:=
xt
.
([]
interface
{})
return
tuple
(
t
),
ok
}
}
// xuint64Unpack tries to retrieve packed 8-byte string as bigendian uint64.
func
(
e
encoding
)
xuint64Unpack
(
xv
interface
{})
(
uint64
,
bool
)
{
switch
e
{
...
...
@@ -347,54 +377,6 @@ func (e encoding) asOid(xv interface{}) (zodb.Oid, bool) {
}
// tuple represents py tuple.
type
tuple
[]
interface
{}
// Tuple converts t into corresponding object appropriate for encoding e.
func
(
e
encoding
)
Tuple
(
t
tuple
)
interface
{}
{
switch
e
{
default
:
panic
(
"bug"
)
case
'Z'
:
// pickle: -> pickle.Tuple
return
pickle
.
Tuple
(
t
)
case
'M'
:
// msgpack: -> leave as tuple
// However shamaton/msgpack encodes tuple(nil) as nil, not empty tuple
// so nil -> tuple{}
if
t
==
nil
{
t
=
tuple
{}
}
return
t
}
}
// asTuple tries to retrieve tuple from corresponding object decoded via encoding e.
func
(
e
encoding
)
asTuple
(
xt
interface
{})
(
tuple
,
bool
)
{
switch
e
{
default
:
panic
(
"bug"
)
case
'Z'
:
// pickle: tuples are represented by pickle.Tuple; lists as []interface{}
switch
t
:=
xt
.
(
type
)
{
case
pickle
.
Tuple
:
return
tuple
(
t
),
true
case
[]
interface
{}
:
return
tuple
(
t
),
true
default
:
return
tuple
(
nil
),
false
}
case
'M'
:
// msgpack: tuples/lists are encoded as arrays; decoded as []interface{}
t
,
ok
:=
xt
.
([]
interface
{})
return
tuple
(
t
),
ok
}
}
// asBytes tries to retrieve bytes from corresponding object decoded via encoding e.
func
(
e
encoding
)
asBytes
(
xb
interface
{})
([]
byte
,
bool
)
{
switch
e
{
...
...
go/zodb/storage/zeo/zeo.go
View file @
2933330b
...
...
@@ -338,7 +338,7 @@ func (r rpc) zeo4Error(arg interface{}) error {
argv
=
args
}
return
r
.
excError
(
exc
,
tuple
(
argv
))
// XXX don't cast?
return
r
.
excError
(
exc
,
tuple
(
argv
))
// XXX don't cast?
XXX
}
// isPyExceptClass returns whether klass represents python exception
...
...
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