Documentation ¶
Index ¶
- Constants
- Variables
- func OverWriteLen(pkg []byte, pkgLen int)
- func OverWriteSeq(pkg []byte, seq uint64)
- func ReadPkg(r *bufio.Reader, headBuf []byte, head *PkgHead, pkgBuf []byte) (pkg []byte, err error)
- type KeyValue
- func (kv *KeyValue) Decode(pkg []byte) (int, error)
- func (kv *KeyValue) Encode(pkg []byte) (int, error)
- func (kv *KeyValue) Length() int
- func (kv *KeyValue) SetCas(cas uint32)
- func (kv *KeyValue) SetColSpace(colSpace uint8)
- func (kv *KeyValue) SetErrCode(errCode int8)
- func (kv *KeyValue) SetScore(score int64)
- func (kv *KeyValue) SetValue(value []byte)
- type PkgDumpReq
- type PkgDumpResp
- type PkgEncoding
- type PkgHead
- type PkgMultiOp
- type PkgOneOp
- type PkgResponse
- type PkgScanReq
- type PkgScanResp
Constants ¶
View Source
const ( CtrlErrCode = 0x1 // Response Error Code CtrlCas = 0x2 // Compare And Switch CtrlColSpace = 0x4 CtrlValue = 0x8 CtrlScore = 0x10 )
CtrlFlag
View Source
const ( ColSpaceDefault = 0 // Default column space ColSpaceScore1 = 1 // rowKey+score+colKey => value ColSpaceScore2 = 2 // rowKey+colKey => value+score )
View Source
const ( // Common flags FlagZop = 0x1 // if set, it is a "Z" op // (Z)Scan flags FlagScanAsc = 0x4 // if set, Scan in ASC order, else DESC order FlagScanKeyStart = 0x8 // if set, Scan start from MIN/MAX key FlagScanEnd = 0x10 // if set, Scan finished, stop now // Dump flags FlagDumpTable = 0x4 // if set, Dump only one table, else Dump current DB(dbId) FlagDumpUnitStart = 0x8 // if set, Dump start from new UnitId, else from pivot record FlagDumpEnd = 0x10 // if set, Dump finished, stop now )
PkgFlag
View Source
const ( // Front CTRL CmdAuth = 0x9 // Front Read CmdPing = 0x10 CmdGet = 0x11 CmdMGet = 0x12 CmdScan = 0x13 CmdDump = 0x14 // Front Write CmdSet = 0x60 CmdMSet = 0x61 CmdDel = 0x62 CmdMDel = 0x63 CmdIncr = 0x64 CmdMIncr = 0x65 // Inner SYNC CmdSync = 0xB0 // Sync data CmdSyncSt = 0xB1 // Sync status // Inner CTRL CmdSlaveOf = 0xD0 CmdMigrate = 0xD1 // Start/Stop migration CmdSlaveSt = 0xD2 // Get migration/slave status CmdDelUnit = 0xD3 // Delete unit data )
View Source
const ( AdminDbId = 255 HeadSize = 14 MaxUint8 = 255 MaxUint16 = 65535 MaxValueLen = 1024 * 1024 // 1MB MaxPkgLen = 1024 * 1024 * 2 // 2MB )
Variables ¶
Functions ¶
func OverWriteLen ¶
func OverWriteSeq ¶
Types ¶
type KeyValue ¶
type KeyValue struct { CtrlFlag uint8 ErrCode int8 // default: 0 if missing ColSpace uint8 // default: 0 if missing TableId uint8 RowKey []byte ColKey []byte Value []byte // default: nil if missing Score int64 // default: 0 if missing Cas uint32 // default: 0 if missing }
KeyValue=cCtrlFlag+cTableId+[cErrCode]+[cColSpace]
+cRowKeyLen+sRowKey+wColKeyLen+sColKey +[dwValueLen+sValue]+[ddwScore]+[dwCas]
func (*KeyValue) SetColSpace ¶
func (*KeyValue) SetErrCode ¶
type PkgDumpReq ¶
type PkgDumpReq struct { StartUnitId uint16 // Dump start unit ID (included) EndUnitId uint16 // Dump finish unit ID (included) PkgOneOp }
Dump PKG=PkgOneOp+wStartUnitId+wEndUnitId
func (*PkgDumpReq) Length ¶
func (p *PkgDumpReq) Length() int
type PkgDumpResp ¶
type PkgDumpResp struct { StartUnitId uint16 EndUnitId uint16 LastUnitId uint16 // Last Unit ID tried to dump PkgMultiOp }
Dump PKG=PkgMultiOp+wStartUnitId+wEndUnitId+wLastUnitId
func (*PkgDumpResp) Length ¶
func (p *PkgDumpResp) Length() int
type PkgEncoding ¶
type PkgHead ¶
type PkgHead struct { Cmd uint8 DbId uint8 Seq uint64 //normal: request seq; replication: master binlog seq PkgLen uint32 }
cCmd+cDbId+ddwSeq+dwPkgLen+sBody
type PkgMultiOp ¶
MGet, MSet, MDel, MZGet, MZSet, MZDel PKG=HEAD+cPkgFlag+cErrCode+wNum+KeyValue[wNum]
func (*PkgMultiOp) Length ¶
func (p *PkgMultiOp) Length() int
func (*PkgMultiOp) SetErrCode ¶
func (p *PkgMultiOp) SetErrCode(errCode int8)
type PkgResponse ¶
type PkgResponse interface { PkgEncoding SetErrCode(errCode int8) }
type PkgScanReq ¶
Scan, ZScan PKG=PkgOneOp+wNum
func (*PkgScanReq) Length ¶
func (p *PkgScanReq) Length() int
Click to show internal directories.
Click to hide internal directories.