Commit e4ff923f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f0da8664
// Copyright (C) 2018-2019 Nexedi SA and Contributors.
// Copyright (C) 2018-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -205,6 +205,8 @@ func (r rpc) excError(exc string, argv []interface{}) error {
// zeo5Error decodes arg of reply with msgExcept flag set and returns
// corresponding error.
func (r rpc) zeo5Error(arg interface{}) error {
// XXX check r.zl.encoding == 'Z' before using pickles?
// ('type', (arg1, arg2, arg3, ...))
texc, ok := arg.(pickle.Tuple)
if !ok || len(texc) != 2 {
......@@ -225,6 +227,8 @@ func (r rpc) zeo5Error(arg interface{}) error {
//
// nil is returned if arg does not represent an exception.
func (r rpc) zeo4Error(arg interface{}) error {
// XXX check r.zl.encoding == 'Z' before using pickles?
// (exc_class, exc_inst), e.g.
// ogórek.Tuple{
// ogórek.Class{Module:"ZODB.POSException", Name:"POSKeyError"},
......
......@@ -31,7 +31,8 @@ import (
"net"
"sync"
pickle "github.com/kisielk/og-rek"
msgpack "github.com/shamaton/msgpack"
pickle "github.com/kisielk/og-rek"
"github.com/someonegg/gocontainer/rbuf"
"lab.nexedi.com/kirr/go123/xbytes"
......@@ -246,10 +247,21 @@ func pktDecodeZ(pkb *pktBuf) (msg, error) {
return m, derrf(".%d: method: got %T; expected str", m.msgid, tpkt[2])
}
m.arg = tpkt[3]
m.arg = tpkt[3] // XXX pickle.Tuple -> tuple
return m, nil
}
// pktDecodeM decodes raw M (msgpack) packet into message.
func pktDecodeM(pkb *pktBuf) (msg, error) {
var m msg
err := msgpack.DecodeStructAsArray(pkb.Payload(), &m)
if err != nil {
return m, err
}
return m, nil
}
// pktEncodeZ encodes message into raw Z (pickle) packet.
func pktEncodeZ(m msg) *pktBuf {
pkb := allocPkb()
......@@ -269,13 +281,15 @@ func pktEncodeZ(m msg) *pktBuf {
return pkb
}
// pktDecodeM decodes raw M (msgpack) packet into message.
func pktDecodeM(pkb *pktBuf) (msg, error) {
panic("TODO")
}
// pktEncodeM encodes message into raw M (msgpack) packet.
func pktEncodeM(m msg) *pktBuf {
panic("TODO")
pkb := allocPkb()
data, err := msgpack.EncodeStructAsArray(m)
if err != nil {
panic(err) // all our types are expected to be supported by msgpack
}
pkb.Write(data) // XXX extra copy
return pkb
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment