binprot

package
v0.0.0-...-d3db570 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2017 License: Apache-2.0 Imports: 11 Imported by: 11

Documentation

Index

Constants

View Source
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)
)
View Source
const ReqHeaderLen = 24

Variables

View Source
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)
)
View Source
var Components protocol.Components = comps{}

Components is the holder for all the different protocol components in the binprot package

View Source
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

func WriteAddCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error

WriteAddCmd writes out the binary representation of an add request header to the given io.Writer

func WriteAppendCmd

func WriteAppendCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error

WriteAppendCmd writes out the binary representation of an append request header to the given io.Writer

func WriteDeleteCmd

func WriteDeleteCmd(w io.Writer, key []byte, opaque uint32) error

WriteDeleteCmd writes out the binary representation of a delete request header to the given io.Writer

func WriteGATCmd

func WriteGATCmd(w io.Writer, key []byte, exptime, opaque uint32) error

WriteGATCmd writes out the binary representation of a get-and-touch request header to the given io.Writer

func WriteGATQCmd

func WriteGATQCmd(w io.Writer, key []byte, exptime, opaque uint32) error

WriteGATQCmd writes out the binary representation of a get-and-touch quiet request header to the given io.Writer

func WriteGetCmd

func WriteGetCmd(w io.Writer, key []byte, opaque uint32) error

WriteGetCmd writes out the binary representation of a get request header to the given io.Writer

func WriteGetECmd

func WriteGetECmd(w io.Writer, key []byte, opaque uint32) error

WriteGetECmd writes out the binary representation of a gete request header to the given io.Writer

func WriteGetEQCmd

func WriteGetEQCmd(w io.Writer, key []byte, opaque uint32) error

WriteGetEQCmd writes out the binary representation of a geteq request header to the given io.Writer

func WriteGetQCmd

func WriteGetQCmd(w io.Writer, key []byte, opaque uint32) error

WriteGetQCmd writes out the binary representation of a getq request header to the given io.Writer

func WriteNoopCmd

func WriteNoopCmd(w io.Writer, opaque uint32) error

WriteNoopCmd writes out the binary representation of a noop request header to the given io.Writer

func WritePrependCmd

func WritePrependCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error

WritePrependCmd writes out the binary representation of a prepend request header to the given io.Writer

func WriteReplaceCmd

func WriteReplaceCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error

WriteReplaceCmd writes out the binary representation of a replace request header to the given io.Writer

func WriteSetCmd

func WriteSetCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error

WriteSetCmd writes out the binary representation of a set request header to the given io.Writer

func WriteTouchCmd

func WriteTouchCmd(w io.Writer, key []byte, exptime, opaque uint32) error

WriteTouchCmd writes out the binary representation of a touch 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

type BinaryResponder

type BinaryResponder struct {
	// contains filtered or unexported fields
}

func NewBinaryResponder

func NewBinaryResponder(writer *bufio.Writer) BinaryResponder

func (BinaryResponder) Add

func (b BinaryResponder) Add(opaque uint32, quiet bool) error

func (BinaryResponder) Append

func (b BinaryResponder) Append(opaque uint32, quiet bool) error

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) GetEnd

func (b BinaryResponder) GetEnd(opaque uint32, noopEnd bool) error

func (BinaryResponder) Noop

func (b BinaryResponder) Noop(opaque uint32) error

func (BinaryResponder) Prepend

func (b BinaryResponder) Prepend(opaque uint32, quiet bool) error

func (BinaryResponder) Quit

func (b BinaryResponder) Quit(opaque uint32, quiet bool) error

func (BinaryResponder) Replace

func (b BinaryResponder) Replace(opaque uint32, quiet bool) error

func (BinaryResponder) Set

func (b BinaryResponder) Set(opaque uint32, quiet bool) error

func (BinaryResponder) Touch

func (b BinaryResponder) Touch(opaque uint32) error

func (BinaryResponder) Version

func (b BinaryResponder) Version(opaque uint32) error

type RequestHeader

type RequestHeader struct {
	Magic           uint8 // Already known, since we're here
	Opcode          uint8
	KeyLength       uint16
	ExtraLength     uint8
	DataType        uint8  // Always 0
	VBucket         uint16 // Not used
	TotalBodyLength uint32
	OpaqueToken     uint32 // Echoed to the client
	CASToken        uint64 // Unused in current implementation
}

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL