oplog

package
v0.0.0-...-ced8162 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const OplogHeaderSize = unsafe.Sizeof(OplogHeader{})

Variables

View Source
var OplogHeaderPrefix = []byte("*2\r\n$6\r\nOPINFO\r\n$32\r\n")

Functions

func ParseInfo

func ParseInfo(content []byte) map[string]string

ParseInfo convert result of info command to map[string]string. For example, "opapply_source_count:1\r\nopapply_source_0:server_id=3171317,applied_opid=1\r\n" is converted to map[string]string{"opapply_source_count": "1", "opapply_source_0": "server_id=3171317,applied_opid=1"}.

func ParsePsyncFullApplyInfo

func ParsePsyncFullApplyInfo(applyinfo string) (map[uint64]int64, error)

ParsePSyncFullResp parse applyinfo which is response of "psync ? -1". For example, applyinfo is "applied_info{0:100,7171317:1867040,1:100}".

func ParseValue

func ParseValue(content string) map[string]string

ParseValue convert value of one item from info command result to map[string]string. For example, "server_id=3171317,applied_opid=1" is converted to map[string]string{"server_id": "3171317", "applied_opid": "1"}.

Types

type FakeOplogMaker

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

func NewFakeOplogMaker

func NewFakeOplogMaker(serverId uint64) *FakeOplogMaker

func (*FakeOplogMaker) MakeFakeOplog

func (p *FakeOplogMaker) MakeFakeOplog(opid int64) (*Oplog, error)

type Oplog

type Oplog struct {
	FullContent []byte
	Header      OplogHeader
	Cmd         []RedisCmd
}

func ParseOplog

func ParseOplog(fullcontent []byte) (*Oplog, error)

func (*Oplog) CmdContent

func (p *Oplog) CmdContent() []byte

func (*Oplog) IsOPLogDelByEviction

func (p *Oplog) IsOPLogDelByEviction() bool

func (*Oplog) IsOPLogDelByExpire

func (p *Oplog) IsOPLogDelByExpire() bool

type OplogHeader

type OplogHeader struct {
	Version   int8
	Status    uint8
	DbId      int16
	Timestamp int32
	ServerId  uint64
	Opid      int64
	SrcOpid   int64
}
struct OplogHeader {
    uint32_t version:8; // version of oplog
    uint32_t cmd_num:4; / number of commands in one oplog, currently 2 or 3
    uint32_t cmd_flag:4;
    uint32_t dbid:16;
    int32_t timestamp;
    int64_t server_id;
    int64_t opid;
    int64_t src_opid; // opid of source redis
};

func ParseOplogHeader

func ParseOplogHeader(content []byte) (*OplogHeader, error)

func (*OplogHeader) GetCmdNum

func (p *OplogHeader) GetCmdNum() int

func (*OplogHeader) IsOPLogDelByEviction

func (p *OplogHeader) IsOPLogDelByEviction() bool

func (*OplogHeader) IsOPLogDelByExpire

func (p *OplogHeader) IsOPLogDelByExpire() bool

func (OplogHeader) String

func (p OplogHeader) String() string

type RedisCmd

type RedisCmd struct {
	CmdCode RedisCmdCode
	Args    [][]byte
}

func (RedisCmd) String

func (p RedisCmd) String() string

type RedisCmdCode

type RedisCmdCode int32
const (
	// redis
	GET RedisCmdCode = iota
	SET
	SETNX
	SETEX
	OPINFO
	PSETEX
	APPEND
	STRLEN
	DEL
	EXISTS
	SETBIT
	GETBIT
	BITFIELD
	SETRANGE
	GETRANGE
	SUBSTR
	INCR
	DECR
	MGET
	RPUSH
	LPUSH
	RPUSHX
	LPUSHX
	LINSERT
	RPOP
	LPOP
	BRPOP
	BRPOPLPUSH
	BLPOP
	LLEN
	LINDEX
	LSET
	LRANGE
	LTRIM
	LREM
	RPOPLPUSH
	SADD
	SREM
	SMOVE
	SISMEMBER
	SCARD
	SPOP
	SRANDMEMBER
	SINTER
	SINTERSTORE
	SUNION
	SUNIONSTORE
	SDIFF
	SDIFFSTORE
	SMEMBERS
	SSCAN
	ZADD
	ZINCRBY
	ZREM
	ZREMRANGEBYSCORE
	ZREMRANGEBYRANK
	ZREMRANGEBYLEX
	ZUNIONSTORE
	ZINTERSTORE
	ZRANGE
	ZRANGEBYSCORE
	ZREVRANGEBYSCORE
	ZRANGEBYLEX
	ZREVRANGEBYLEX
	ZCOUNT
	ZLEXCOUNT
	ZREVRANGE
	ZCARD
	ZSCORE
	ZRANK
	ZREVRANK
	ZSCAN
	HSET
	HSETNX
	HGET
	HMSET
	HMGET
	HINCRBY
	HINCRBYFLOAT
	HDEL
	HLEN
	HSTRLEN
	HKEYS
	HVALS
	HGETALL
	HEXISTS
	HSCAN
	INCRBY
	DECRBY
	INCRBYFLOAT
	GETSET
	MSET
	MSETNX
	RANDOMKEY
	SELECT
	MOVE
	RENAME
	RENAMENX
	EXPIRE
	EXPIREAT
	PEXPIRE
	PEXPIREAT
	KEYS
	SCAN
	ISCAN
	DBSIZE
	AUTH
	PING
	ECHO
	// SAVE
	// BGSAVE
	// BGREWRITEAOF
	// SHUTDOWN
	// LASTSAVE
	TYPE
	MULTI
	EXEC
	DISCARD
	// SYNC
	// PSYNC
	// REPLCONF
	FLUSHDB
	FLUSHALL
	SORT
	INFO
	IINFO
	// MONITOR
	TTL
	PTTL
	PERSIST
	// SLAVEOF
	// ROLE
	// DEBUG
	CONFIG
	SUBSCRIBE
	UNSUBSCRIBE
	PSUBSCRIBE
	PUNSUBSCRIBE
	PUBLISH
	PUBSUB
	WATCH
	UNWATCH
	// CLUSTER
	RESTORE
	// RESTORE-ASKING
	// MIGRATE
	// ASKING
	// READONLY
	// READWRITE
	DUMP
	OBJECT
	// CLIENT
	EVAL
	EVALSHA
	SLOWLOG
	SCRIPT
	TIME
	BITOP
	BITCOUNT
	BITPOS
	// WAIT
	// COMMAND
	GEOADD
	GEORADIUS
	GEORADIUSBYMEMBER
	GEOHASH
	GEOPOS
	GEODIST
	// PFSELFTEST
	PFADD
	PFCOUNT
	PFMERGE

	QUIT
	UNKOWN
	CMD_CODE_END
)

func ParseCommandStrToCode

func ParseCommandStrToCode(cmd []byte) RedisCmdCode

type RedisInfoOplog

type RedisInfoOplog struct {
	CurrentOpid int64
	GtidSet     map[uint64]int64 // serverId --> opid
	OpdelOpid   map[string]int64
}

func ParseRedisInfoOplog

func ParseRedisInfoOplog(oplogInfo []byte) (*RedisInfoOplog, error)

ParseRedisOplogInfo convert result of info oplog to map[uint64]int64(<serverID> --> <appliedOpid>).

info oplog reply example:

# Oplog
current_opid:1
opapply_source_count:1
opapply_source_0:server_id=3171317,applied_opid=1
opdel_source_count:2
opdel_source_0:source_name=bls_channel_02,to_del_opid=1,last_update_time=1500279590
opdel_source_1:source_name=bls_channel_01,to_del_opid=1,last_update_time=1500279587

Jump to

Keyboard shortcuts

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