mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-11 09:06:14 +00:00
Update etcd client to 3.3.9
This commit is contained in:
35
vendor/github.com/ugorji/go/codec/rpc.go
generated
vendored
35
vendor/github.com/ugorji/go/codec/rpc.go
generated
vendored
@@ -5,18 +5,19 @@ package codec
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"io"
|
||||
"net/rpc"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// rpcEncodeTerminator allows a handler specify a []byte terminator to send after each Encode.
|
||||
//
|
||||
// Some codecs like json need to put a space after each encoded value, to serve as a
|
||||
// delimiter for things like numbers (else json codec will continue reading till EOF).
|
||||
type rpcEncodeTerminator interface {
|
||||
rpcEncodeTerminate() []byte
|
||||
}
|
||||
// // rpcEncodeTerminator allows a handler specify a []byte terminator to send after each Encode.
|
||||
// //
|
||||
// // Some codecs like json need to put a space after each encoded value, to serve as a
|
||||
// // delimiter for things like numbers (else json codec will continue reading till EOF).
|
||||
// type rpcEncodeTerminator interface {
|
||||
// rpcEncodeTerminate() []byte
|
||||
// }
|
||||
|
||||
// Rpc provides a rpc Server or Client Codec for rpc communication.
|
||||
type Rpc interface {
|
||||
@@ -52,6 +53,12 @@ type rpcCodec struct {
|
||||
func newRPCCodec(conn io.ReadWriteCloser, h Handle) rpcCodec {
|
||||
bw := bufio.NewWriter(conn)
|
||||
br := bufio.NewReader(conn)
|
||||
|
||||
// defensive: ensure that jsonH has TermWhitespace turned on.
|
||||
if jsonH, ok := h.(*JsonHandle); ok && !jsonH.TermWhitespace {
|
||||
panic(errors.New("rpc requires a JsonHandle with TermWhitespace set to true"))
|
||||
}
|
||||
|
||||
return rpcCodec{
|
||||
rwc: conn,
|
||||
bw: bw,
|
||||
@@ -77,17 +84,17 @@ func (c *rpcCodec) write(obj1, obj2 interface{}, writeObj2, doFlush bool) (err e
|
||||
if err = c.enc.Encode(obj1); err != nil {
|
||||
return
|
||||
}
|
||||
t, tOk := c.h.(rpcEncodeTerminator)
|
||||
if tOk {
|
||||
c.bw.Write(t.rpcEncodeTerminate())
|
||||
}
|
||||
// t, tOk := c.h.(rpcEncodeTerminator)
|
||||
// if tOk {
|
||||
// c.bw.Write(t.rpcEncodeTerminate())
|
||||
// }
|
||||
if writeObj2 {
|
||||
if err = c.enc.Encode(obj2); err != nil {
|
||||
return
|
||||
}
|
||||
if tOk {
|
||||
c.bw.Write(t.rpcEncodeTerminate())
|
||||
}
|
||||
// if tOk {
|
||||
// c.bw.Write(t.rpcEncodeTerminate())
|
||||
// }
|
||||
}
|
||||
if doFlush {
|
||||
return c.bw.Flush()
|
||||
|
||||
Reference in New Issue
Block a user