Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeError(header *ResponseHeader) error
- func PutResponseHeader(rh *ResponseHeader)
- func WriteAddCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error
- func WriteAppendCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error
- func WriteDeleteCmd(w io.Writer, key []byte, opaque uint32) error
- func WriteGATCmd(w io.Writer, key []byte, exptime, opaque uint32) error
- func WriteGATQCmd(w io.Writer, key []byte, exptime, opaque uint32) error
- func WriteGetCmd(w io.Writer, key []byte, opaque uint32) error
- func WriteGetECmd(w io.Writer, key []byte, opaque uint32) error
- func WriteGetEQCmd(w io.Writer, key []byte, opaque uint32) error
- func WriteGetQCmd(w io.Writer, key []byte, opaque uint32) error
- func WriteNoopCmd(w io.Writer, opaque uint32) error
- func WritePrependCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error
- func WriteReplaceCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error
- func WriteSetCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error
- func WriteTouchCmd(w io.Writer, key []byte, exptime, opaque uint32) error
- type BinaryParser
- type BinaryResponder
- func (b BinaryResponder) Add(opaque uint32, quiet bool) error
- func (b BinaryResponder) Append(opaque uint32, quiet bool) error
- func (b BinaryResponder) Delete(opaque uint32) error
- func (b BinaryResponder) Error(opaque uint32, reqType common.RequestType, err error, quiet bool) error
- func (b BinaryResponder) GAT(response common.GetResponse) error
- func (b BinaryResponder) Get(response common.GetResponse) error
- func (b BinaryResponder) GetE(response common.GetEResponse) error
- func (b BinaryResponder) GetEnd(opaque uint32, noopEnd bool) error
- func (b BinaryResponder) Noop(opaque uint32) error
- func (b BinaryResponder) Prepend(opaque uint32, quiet bool) error
- func (b BinaryResponder) Quit(opaque uint32, quiet bool) error
- func (b BinaryResponder) Replace(opaque uint32, quiet bool) error
- func (b BinaryResponder) Set(opaque uint32, quiet bool) error
- func (b BinaryResponder) Touch(opaque uint32) error
- func (b BinaryResponder) Version(opaque uint32) error
- type RequestHeader
- type ResponseHeader
Constants ¶
const ( MagicRequest = uint8(0x80) MagicResponse = uint8(0x81) // All opcodes as defined in memcached // Minus SASL and range ops OpcodeGet = uint8(0x00) OpcodeSet = uint8(0x01) OpcodeAdd = uint8(0x02) OpcodeReplace = uint8(0x03) OpcodeDelete = uint8(0x04) OpcodeIncrement = uint8(0x05) OpcodeDecrement = uint8(0x06) OpcodeQuit = uint8(0x07) OpcodeFlush = uint8(0x08) OpcodeGetQ = uint8(0x09) OpcodeNoop = uint8(0x0a) OpcodeVersion = uint8(0x0b) OpcodeGetK = uint8(0x0c) OpcodeGetKQ = uint8(0x0d) OpcodeAppend = uint8(0x0e) OpcodePrepend = uint8(0x0f) OpcodeStat = uint8(0x10) OpcodeSetQ = uint8(0x11) OpcodeAddQ = uint8(0x12) OpcodeReplaceQ = uint8(0x13) OpcodeDeleteQ = uint8(0x14) OpcodeIncrementQ = uint8(0x15) OpcodeDecrementQ = uint8(0x16) OpcodeQuitQ = uint8(0x17) OpcodeFlushQ = uint8(0x18) OpcodeAppendQ = uint8(0x19) OpcodePrependQ = uint8(0x1a) OpcodeTouch = uint8(0x1c) OpcodeGat = uint8(0x1d) OpcodeGatQ = uint8(0x1e) OpcodeGatK = uint8(0x23) OpcodeGatKQ = uint8(0x24) OpcodeInvalid = uint8(0xFF) OpcodeGetE = uint8(0x40) OpcodeGetEQ = uint8(0x41) StatusSuccess = uint16(0x00) StatusKeyEnoent = uint16(0x01) StatusKeyExists = uint16(0x02) StatusE2big = uint16(0x03) StatusEinval = uint16(0x04) StatusNotStored = uint16(0x05) StatusDeltaBadval = uint16(0x06) StatusAuthError = uint16(0x20) StatusAuthContinue = uint16(0x21) StatusUnknownCommand = uint16(0x81) StatusEnomem = uint16(0x82) StatusNotSupported = uint16(0x83) StatusInternalError = uint16(0x84) StatusBusy = uint16(0x85) StatusTempFailure = uint16(0x86) StatusInvalid = uint16(0xFFFF) )
const ReqHeaderLen = 24
Variables ¶
var ( MetricBinaryRequestHeadersParsed = metrics.AddCounter("binary_request_headers_parsed", nil) MetricBinaryRequestHeadersBadMagic = metrics.AddCounter("binary_request_headers_bad_magic", nil) MetricBinaryResponseHeadersParsed = metrics.AddCounter("binary_response_headers_parsed", nil) MetricBinaryResponseHeadersBadMagic = metrics.AddCounter("binary_response_headers_bad_magic", nil) )
var Components protocol.Components = comps{}
Components is the holder for all the different protocol components in the binprot package
var ErrBadMagic = errors.New("Bad magic value")
Functions ¶
func DecodeError ¶
func DecodeError(header *ResponseHeader) error
func PutResponseHeader ¶
func PutResponseHeader(rh *ResponseHeader)
PutResponseHeader returns the response header to the pool
func WriteAddCmd ¶
WriteAddCmd writes out the binary representation of an add request header to the given io.Writer
func WriteAppendCmd ¶
WriteAppendCmd writes out the binary representation of an append request header to the given io.Writer
func WriteDeleteCmd ¶
WriteDeleteCmd writes out the binary representation of a delete request header to the given io.Writer
func WriteGATCmd ¶
WriteGATCmd writes out the binary representation of a get-and-touch request header to the given io.Writer
func WriteGATQCmd ¶
WriteGATQCmd writes out the binary representation of a get-and-touch quiet request header to the given io.Writer
func WriteGetCmd ¶
WriteGetCmd writes out the binary representation of a get request header to the given io.Writer
func WriteGetECmd ¶
WriteGetECmd writes out the binary representation of a gete request header to the given io.Writer
func WriteGetEQCmd ¶
WriteGetEQCmd writes out the binary representation of a geteq request header to the given io.Writer
func WriteGetQCmd ¶
WriteGetQCmd writes out the binary representation of a getq request header to the given io.Writer
func WriteNoopCmd ¶
WriteNoopCmd writes out the binary representation of a noop request header to the given io.Writer
func WritePrependCmd ¶
WritePrependCmd writes out the binary representation of a prepend request header to the given io.Writer
func WriteReplaceCmd ¶
WriteReplaceCmd writes out the binary representation of a replace request header to the given io.Writer
func WriteSetCmd ¶
WriteSetCmd writes out the binary representation of a set request header to the given io.Writer
Types ¶
type BinaryParser ¶
type BinaryParser struct {
// contains filtered or unexported fields
}
func NewBinaryParser ¶
func NewBinaryParser(reader *bufio.Reader) BinaryParser
func (BinaryParser) Parse ¶
func (b BinaryParser) Parse() (common.Request, common.RequestType, uint64, error)
type BinaryResponder ¶
type BinaryResponder struct {
// contains filtered or unexported fields
}
func NewBinaryResponder ¶
func NewBinaryResponder(writer *bufio.Writer) BinaryResponder
func (BinaryResponder) Delete ¶
func (b BinaryResponder) Delete(opaque uint32) error
func (BinaryResponder) Error ¶
func (b BinaryResponder) Error(opaque uint32, reqType common.RequestType, err error, quiet bool) error
func (BinaryResponder) GAT ¶
func (b BinaryResponder) GAT(response common.GetResponse) error
func (BinaryResponder) Get ¶
func (b BinaryResponder) Get(response common.GetResponse) error
func (BinaryResponder) GetE ¶
func (b BinaryResponder) GetE(response common.GetEResponse) error
func (BinaryResponder) Noop ¶
func (b BinaryResponder) Noop(opaque uint32) error
func (BinaryResponder) Touch ¶
func (b BinaryResponder) Touch(opaque uint32) error
func (BinaryResponder) Version ¶
func (b BinaryResponder) Version(opaque uint32) error
type RequestHeader ¶
type ResponseHeader ¶
type ResponseHeader struct { Magic uint8 // always 0x81 Opcode uint8 KeyLength uint16 ExtraLength uint8 DataType uint8 // unused, always 0 Status uint16 TotalBodyLength uint32 OpaqueToken uint32 // same as the user passed in CASToken uint64 }
func ReadResponseHeader ¶
func ReadResponseHeader(r io.Reader) (*ResponseHeader, error)