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
ca25c79d
Commit
ca25c79d
authored
Jul 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
37ce0f83
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
go/zodb/storage/zeo/zrpc.go
go/zodb/storage/zeo/zrpc.go
+78
-0
No files found.
go/zodb/storage/zeo/zrpc.go
View file @
ca25c79d
...
...
@@ -31,6 +31,7 @@ import (
"net"
"sync"
msgp
"github.com/tinylib/msgp/msgp"
msgpack
"github.com/shamaton/msgpack"
pickle
"github.com/kisielk/og-rek"
...
...
@@ -266,6 +267,82 @@ func pktDecodeZ(pkb *pktBuf) (msg, error) {
// pktDecodeM decodes raw M (msgpack) packet into message.
func
pktDecodeM
(
pkb
*
pktBuf
)
(
msg
,
error
)
{
var
m
msg
b
:=
pkb
.
Payload
()
// must be (msgid, False|0, "method", arg)
l
,
b
,
err
:=
msgp
.
ReadArrayHeaderBytes
(
b
)
if
err
!=
nil
{
return
m
,
derrf
(
"%s"
,
err
)
}
if
l
!=
4
{
return
m
,
derrf
(
"len(msg-tuple)=%d; expected 4"
,
l
)
}
// msgid
v
:=
int64
(
0
)
switch
t
:=
msgp
.
NextType
(
b
);
t
{
case
msgp
.
IntType
:
v
,
b
,
err
=
msgp
.
ReadInt64Bytes
(
b
)
case
msgp
.
UintType
:
var
x
uint64
x
,
b
,
err
=
msgp
.
ReadUint64Bytes
(
b
)
v
=
int64
(
x
)
default
:
err
=
fmt
.
Errorf
(
"got %s; expected int"
,
t
)
}
if
err
!=
nil
{
return
m
,
derrf
(
"msgid: %s"
,
err
)
}
m
.
msgid
=
v
// flags
v
=
int64
(
0
)
switch
t
:=
msgp
.
NextType
(
b
);
t
{
case
msgp
.
BoolType
:
var
x
bool
x
,
b
,
err
=
msgp
.
ReadBoolBytes
(
b
)
if
x
{
v
=
1
}
case
msgp
.
IntType
:
v
,
b
,
err
=
msgp
.
ReadInt64Bytes
(
b
)
case
msgp
.
UintType
:
var
x
uint64
x
,
b
,
err
=
msgp
.
ReadUint64Bytes
(
b
)
v
=
int64
(
x
)
default
:
err
=
fmt
.
Errorf
(
"got %s; expected int|bool"
,
t
)
}
if
err
!=
nil
{
return
m
,
derrf
(
"flags: %s"
,
err
)
}
// XXX check flags are in range?
m
.
flags
=
msgFlags
(
v
)
// method
m
.
method
,
b
,
err
=
msgp
.
ReadStringBytes
(
b
)
if
err
!=
nil
{
return
m
,
derrf
(
".%d: method: %s"
,
m
.
msgid
,
err
)
}
// arg
// it is interface{} - use shamaton/msgpack since msgp does not handle
// arbitrary interfaces well.
btail
,
err
:=
msgp
.
Skip
(
b
)
if
err
!=
nil
{
return
m
,
derrf
(
".%d: arg: %s"
,
m
.
msgid
,
err
)
}
if
len
(
btail
)
!=
0
{
return
m
,
derrf
(
".%d: payload has extra data after message"
)
}
err
=
msgpack
.
Decode
(
b
,
&
m
.
arg
)
if
err
!=
nil
{
return
m
,
derrf
(
".%d: arg: %s"
,
m
.
msgid
,
err
)
}
return
m
,
nil
/*
m.msgid, b, err = msgp.
//err := msgpack.DecodeStructAsArray(pkb.Payload(), &m)
var tpkt tuple
err := msgpack.Decode(pkb.Payload(), &tpkt)
...
...
@@ -303,6 +380,7 @@ func pktDecodeM(pkb *pktBuf) (msg, error) {
m.arg = tpkt[3] // XXX []interface{} -> tuple
return m, nil
*/
}
...
...
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