Commit e507f6d7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 88155c17
......@@ -72,7 +72,8 @@ type zLink struct {
down1 sync.Once
errClose error // error got from .link.Close()
ver string // protocol verision in use (without "Z" or "M" prefix)
ver string // protocol version in use (without "Z" or "M" prefix)
encoding byte // protocol encoding in use ('Z' or 'M')
}
// (called after handshake)
......@@ -136,7 +137,7 @@ func (zl *zLink) serveRecv() {
// serveRecv1 handles 1 incoming packet.
func (zl *zLink) serveRecv1(pkb *pktBuf) error {
// decode packet
m, err := pktDecode(pkb)
m, err := zl.pktDecode(pkb)
if err != nil {
return err
}
......@@ -189,8 +190,17 @@ func derrf(format string, argv ...interface{}) error {
return fmt.Errorf("decode: "+format, argv...)
}
// pktDecode decodes raw packet into message
func pktDecode(pkb *pktBuf) (msg, error) {
// pktDecode decodes raw packet into message.
func (zl *zLink) pktDecode(pkb *pktBuf) (msg, error) {
switch zl.encoding {
case 'Z': return pktDecodeZ(pkb)
case 'M': return pktDecodeM(pkb)
default: panic("bug")
}
}
// pktDecodeZ decodes raw Z (pickle) packet into message.
func pktDecodeZ(pkb *pktBuf) (msg, error) {
var m msg
// must be (msgid, False|0, ".reply", res)
d := pickle.NewDecoder(bytes.NewReader(pkb.Payload()))
......@@ -227,6 +237,11 @@ func pktDecode(pkb *pktBuf) (msg, error) {
return m, nil
}
// pktDecodeM decodes raw M (msgpack) packet into message.
func pktDecodeM(pkb *pktBuf) (msg, error) {
panic("TODO")
}
// Call makes 1 RPC call to server, waits for reply and returns it.
func (zl *zLink) Call(ctx context.Context, method string, argv ...interface{}) (reply msg, _ error) {
......
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