Documentation
¶
Overview ¶
core struct cmd op interface driver
Index ¶
- Constants
- Variables
- func ListRespCmdSrvs() []string
- func ListStoragers() []string
- func MergeRegisteredCmdHandles(src, dst map[string]CmdHandle, isDelSrc bool)
- func RegisterCmd(cmdType, cmd string, handle CmdHandle)
- func RegisterDumpHandler(name DumpSrvInfoName, handler DumpHandler)
- func RegisterRespCmdSrv(s IRespService) error
- func RegisterStorager(s IStorager) error
- func RegisterWriteCmdAtApply(cmdType, cmd string, handle CmdHandle)
- func RegisterWriteCmdAtPropose(cmdType, cmd string, handle CmdHandle)
- func RegisteredReadCmdAtApply(cmdType, cmd string, handle CmdHandle)
- func RegisteredReadCmdAtPropose(cmdType, cmd string, handle CmdHandle)
- type CmdHandle
- type DumpHandler
- type DumpSrvInfoName
- type FVPair
- type IBitmapCmd
- type ICommonCmd
- type IDB
- type IDBSlots
- type IHashCmd
- type IListCmd
- type IReplicaSrvConnCmd
- type IRespConn
- type IRespService
- type ISetCmd
- type ISlotsCmd
- type ISrvInfo
- type IStatsStorager
- type IStorager
- type IStringCmd
- type IZsetCmd
- type InfoPair
- type KVPair
- type RangeType
- type RespConnBase
- func (c *RespConnBase) Close() error
- func (c *RespConnBase) Db() (db IDB)
- func (c *RespConnBase) DoCmd(ctx context.Context, cmd string, cmdParams [][]byte) (res interface{}, err error)
- func (c *RespConnBase) Name() (name string)
- func (c *RespConnBase) SetConnName(name string)
- func (c *RespConnBase) SetDb(db IDB)
- func (c *RespConnBase) SetStorager(store IStorager)
- func (c *RespConnBase) Storager() (store IStorager)
- type RespServiceName
- type ScorePair
- type SlotInfo
- type SlotsRestoreObj
Constants ¶
View Source
const ( CmdTypeSrv = "srv" CmdTypeReplica = "replica" CmdTypeBitmap = "bitmap" CmdTypeString = "string" CmdTypeHash = "hash" CmdTypeList = "list" CmdTypeSet = "set" CmdTypeZset = "zset" CmdTypeSlot = "slot" )
Variables ¶
View Source
var RegisteredCmdHandles = map[string]CmdHandle{}
View Source
var RegisteredCmdSet = map[string][]string{}
View Source
var RegisteredDumpHandlerNames = []DumpSrvInfoName{}
View Source
var RegisteredDumpHandlers = map[DumpSrvInfoName]DumpHandler{}
View Source
var RegisteredReadCmdAtApplyHandles = map[string]CmdHandle{}
View Source
var RegisteredReadCmdAtProposeHandles = map[string]CmdHandle{}
View Source
var RegisteredReplicaCmdHandles = map[string]CmdHandle{}
View Source
var RegisteredWriteCmdAtApplyHandles = map[string]CmdHandle{}
View Source
var RegisteredWriteCmdAtProposeHandles = map[string]CmdHandle{}
Functions ¶
func ListRespCmdSrvs ¶
func ListRespCmdSrvs() []string
func ListStoragers ¶
func ListStoragers() []string
func RegisterCmd ¶
RegisterCmd register all cmd
func RegisterDumpHandler ¶
func RegisterDumpHandler(name DumpSrvInfoName, handler DumpHandler)
func RegisterRespCmdSrv ¶
func RegisterRespCmdSrv(s IRespService) error
func RegisterStorager ¶
func RegisterWriteCmdAtApply ¶
RegisterWriteCmdAtApply
func RegisterWriteCmdAtPropose ¶
RegisterWriteCmdAtPropose
func RegisteredReadCmdAtApply ¶
RegisterReadCmdAtApply
func RegisteredReadCmdAtPropose ¶
RegisterReadCmdAtPropose
Types ¶
type DumpHandler ¶
type DumpSrvInfoName ¶
type DumpSrvInfoName string
func (DumpSrvInfoName) FirstToUp ¶
func (name DumpSrvInfoName) FirstToUp() []byte
func (DumpSrvInfoName) RespDumpName ¶
func (name DumpSrvInfoName) RespDumpName() []byte
func (DumpSrvInfoName) ToLow ¶
func (name DumpSrvInfoName) ToLow() []byte
type IBitmapCmd ¶
type IBitmapCmd interface { BitOP(ctx context.Context, op string, destKey []byte, srcKeys ...[]byte) (int64, error) BitCount(ctx context.Context, key []byte, start int, end int) (int64, error) BitPos(ctx context.Context, key []byte, on int, start int, end int) (int64, error) SetBit(ctx context.Context, key []byte, offset int, on int) (int64, error) GetBit(ctx context.Context, key []byte, offset int) (int64, error) }
type ICommonCmd ¶
type ICommonCmd interface { Del(ctx context.Context, keys ...[]byte) (int64, error) Exists(ctx context.Context, key []byte) (int64, error) // for ttl Expire(ctx context.Context, key []byte, duration int64) (int64, error) ExpireAt(ctx context.Context, key []byte, when int64) (int64, error) TTL(ctx context.Context, key []byte) (int64, error) Persist(ctx context.Context, key []byte) (int64, error) }
adapt https://redis.io/commands/?group=generic some common key op cmd
type IDB ¶
type IDB interface { FlushDB(ctx context.Context) (drop int64, err error) DBString() IStringCmd DBList() IListCmd DBHash() IHashCmd DBSet() ISetCmd DBZSet() IZsetCmd DBBitmap() IBitmapCmd }
type IHashCmd ¶
type IHashCmd interface { HSet(ctx context.Context, key []byte, field []byte, value []byte) (int64, error) HGet(ctx context.Context, key []byte, field []byte) ([]byte, error) HLen(ctx context.Context, key []byte) (int64, error) HMset(ctx context.Context, key []byte, args ...FVPair) error HMget(ctx context.Context, key []byte, args ...[]byte) ([][]byte, error) HDel(ctx context.Context, key []byte, args ...[]byte) (int64, error) HIncrBy(ctx context.Context, key []byte, field []byte, delta int64) (int64, error) HGetAll(ctx context.Context, key []byte) ([]FVPair, error) HKeys(ctx context.Context, key []byte) ([][]byte, error) HValues(ctx context.Context, key []byte) ([][]byte, error) ICommonCmd }
type IListCmd ¶
type IListCmd interface { LIndex(ctx context.Context, key []byte, index int32) ([]byte, error) LLen(ctx context.Context, key []byte) (int64, error) LPop(ctx context.Context, key []byte) ([]byte, error) LTrim(ctx context.Context, key []byte, start, stop int64) error LTrimFront(ctx context.Context, key []byte, trimSize int32) (int32, error) LTrimBack(ctx context.Context, key []byte, trimSize int32) (int32, error) LPush(ctx context.Context, key []byte, args ...[]byte) (int64, error) LSet(ctx context.Context, key []byte, index int32, value []byte) error LRange(ctx context.Context, key []byte, start int32, stop int32) ([][]byte, error) RPop(ctx context.Context, key []byte) ([]byte, error) RPush(ctx context.Context, key []byte, args ...[]byte) (int64, error) BLPop(ctx context.Context, keys [][]byte, timeout time.Duration) ([]interface{}, error) BRPop(ctx context.Context, keys [][]byte, timeout time.Duration) ([]interface{}, error) ICommonCmd }
type IReplicaSrvConnCmd ¶
type IReplicaSrvConnCmd interface { // Replicaof client cmd in slave Replicaof(ctx context.Context, string, restart bool, readonly bool) error // Sync internal cmd for slave send sync cmd to master, // slave pull buf (sync logs) Sync(ctx context.Context, syncLogID uint64) (buf []byte, err error) // Sync internal cmd for slave send fullsync cmd to master, // slave pull master's snapshot file which dump from data kvstore(FSM), // then write to connFD (io.CopyN) FullSync(ctx context.Context, needNew bool) (err error) }
type IRespConn ¶
type IRespConn interface { SetStorager(db IStorager) Storager() (store IStorager) SetDb(db IDB) Db() (db IDB) SetConnName(name string) Name() (name string) DoCmd(ctx context.Context, cmd string, cmdParams [][]byte) (res interface{}, err error) Close() error }
IRespConn resp conn session
type IRespService ¶
type IRespService interface { // Start service Start(ctx context.Context) (err error) // InitRespConn init resp connect session by select db index, // return IRespConn interface InitRespConn(ctx context.Context, dbIdx int) IRespConn // Close resp service Close() (err error) // Name Name() RespServiceName // SetStorager SetStorager(store IStorager) }
func GetRespCmdSrv ¶
func GetRespCmdSrv(name RespServiceName) (IRespService, error)
type ISetCmd ¶
type ISetCmd interface { SAdd(ctx context.Context, key []byte, args ...[]byte) (int64, error) SCard(ctx context.Context, key []byte) (int64, error) SDiff(ctx context.Context, keys ...[]byte) ([][]byte, error) SDiffStore(ctx context.Context, dstKey []byte, keys ...[]byte) (int64, error) SInter(ctx context.Context, keys ...[]byte) ([][]byte, error) SInterStore(ctx context.Context, dstKey []byte, keys ...[]byte) (int64, error) SIsMember(ctx context.Context, key []byte, member []byte) (int64, error) SMembers(ctx context.Context, key []byte) ([][]byte, error) SRem(ctx context.Context, key []byte, args ...[]byte) (int64, error) SUnion(ctx context.Context, keys ...[]byte) ([][]byte, error) SUnionStore(ctx context.Context, dstKey []byte, keys ...[]byte) (int64, error) ICommonCmd }
type ISlotsCmd ¶
type ISlotsCmd interface { // MigrateSlotOneKey migrate slot one key/val to addr with timeout (ms) // return 1, success, 0 slot is empty MigrateSlotOneKey(ctx context.Context, addr string, timeout time.Duration, slot uint64) (int64, error) // MigrateSlotKeyWithSameTag migrate slot keys/vals which have the same tag with one key to addr with timeout (ms) // return n, success, 0 slot is empty MigrateSlotKeyWithSameTag(ctx context.Context, addr string, timeout time.Duration, slot uint64) (int64, error) // MigrateOneKey migrate one key/val (no hash tag tag=key) to addr with timeout (ms) // return n (same key, diff dataType), success, 0 slot is empty MigrateOneKey(ctx context.Context, addr string, timeout time.Duration, key []byte) (int64, error) // MigrateKeyWithSameTag migrate keys/vals which have the same tag with one key to addr with timeout (ms) // return n, n migrate success, 0 slot is empty MigrateKeyWithSameTag(ctx context.Context, addr string, timeout time.Duration, key []byte) (int64, error) // SlotsRestore dest migrate addr restore slot obj [key ttlms serialized-value(rdb) ...] SlotsRestore(ctx context.Context, objs ...*SlotsRestoreObj) error // SlotsInfo show slot info with slots range [start,start+count] // return slotInfo slice // if withSize is true, slotInfo.Size is keys cn; else exits key is 1, or 0 SlotsInfo(ctx context.Context, startSlot, count uint64, withSize bool) ([]*SlotInfo, error) // SlotsHashKey hash keys to slots, return slot slice SlotsHashKey(ctx context.Context, keys ...[]byte) ([]uint64, error) // SlotsDel del slots, return after del slot info SlotsDel(ctx context.Context, slots ...uint64) ([]*SlotInfo, error) // SlotsCheck slots must check below case // - The key stored in each slot can find the corresponding val in the db // - Keys in each db can be found in the corresponding slot // WARNING: just used debug/test, don't use in product, SlotsCheck(ctx context.Context) error }
type ISrvInfo ¶
type ISrvInfo interface {
DumpBytes(name DumpSrvInfoName) []byte
}
type IStatsStorager ¶
type IStorager ¶
type IStorager interface { Select(ctx context.Context, index int) (db IDB, err error) FlushAll(ctx context.Context) error Open(ctx context.Context) error Close() error Name() string }
func GetStorager ¶
type IStringCmd ¶
type IStringCmd interface { Set(ctx context.Context, key []byte, value []byte) error SetNX(ctx context.Context, key []byte, value []byte) (n int64, err error) SetEX(ctx context.Context, key []byte, duration int64, value []byte) error SetNXEX(ctx context.Context, key []byte, duration int64, value []byte) (n int64, err error) SetXXEX(ctx context.Context, key []byte, duration int64, value []byte) (n int64, err error) Get(ctx context.Context, key []byte) ([]byte, error) GetSlice(ctx context.Context, key []byte) (openkvdriver.ISlice, error) GetSet(ctx context.Context, key []byte, value []byte) ([]byte, error) Incr(ctx context.Context, key []byte) (int64, error) IncrBy(ctx context.Context, key []byte, increment int64) (int64, error) Decr(ctx context.Context, key []byte) (int64, error) DecrBy(ctx context.Context, key []byte, decrement int64) (int64, error) MGet(ctx context.Context, keys ...[]byte) ([][]byte, error) MSet(ctx context.Context, args ...KVPair) error SetRange(ctx context.Context, key []byte, offset int, value []byte) (int64, error) GetRange(ctx context.Context, key []byte, start int, end int) ([]byte, error) StrLen(ctx context.Context, key []byte) (int64, error) Append(ctx context.Context, key []byte, value []byte) (int64, error) ICommonCmd }
type IZsetCmd ¶
type IZsetCmd interface { ZAdd(ctx context.Context, key []byte, args ...ScorePair) (int64, error) ZCard(ctx context.Context, key []byte) (int64, error) ZScore(ctx context.Context, key []byte, member []byte) (int64, error) ZRem(ctx context.Context, key []byte, members ...[]byte) (int64, error) ZIncrBy(ctx context.Context, key []byte, delta int64, member []byte) (int64, error) ZCount(ctx context.Context, key []byte, min int64, max int64) (int64, error) ZRank(ctx context.Context, key []byte, member []byte) (int64, error) ZRemRangeByRank(ctx context.Context, key []byte, start int, stop int) (int64, error) ZRemRangeByScore(ctx context.Context, key []byte, min int64, max int64) (int64, error) ZRevRange(ctx context.Context, key []byte, start int, stop int) ([]ScorePair, error) ZRevRank(ctx context.Context, key []byte, member []byte) (int64, error) ZRevRangeByScore(ctx context.Context, key []byte, min int64, max int64, offset int, count int) ([]ScorePair, error) ZRangeGeneric(ctx context.Context, key []byte, start int, stop int, reverse bool) ([]ScorePair, error) ZRangeByScoreGeneric(ctx context.Context, key []byte, min int64, max int64, offset int, count int, reverse bool) ([]ScorePair, error) ZUnionStore(ctx context.Context, destKey []byte, srcKeys [][]byte, weights []int64, aggregate []byte) (int64, error) ZInterStore(ctx context.Context, destKey []byte, srcKeys [][]byte, weights []int64, aggregate []byte) (int64, error) ZRangeByLex(ctx context.Context, key []byte, min []byte, max []byte, rangeType RangeType, offset int, count int) ([][]byte, error) ZRemRangeByLex(ctx context.Context, key []byte, min []byte, max []byte, rangeType RangeType) (int64, error) ZLexCount(ctx context.Context, key []byte, min []byte, max []byte, rangeType RangeType) (int64, error) ICommonCmd }
type InfoPair ¶
type InfoPair struct { Key string Value interface{} }
func (InfoPair) RespDumpInfo ¶
type RangeType ¶
type RangeType uint8
RangeType:
RangeClose: [min, max] RangeLopen: (min, max] RangeRopen: [min, max) RangeOpen: (min, max)
type RespConnBase ¶
type RespConnBase struct {
// contains filtered or unexported fields
}
func (*RespConnBase) Close ¶
func (c *RespConnBase) Close() error
func (*RespConnBase) Db ¶
func (c *RespConnBase) Db() (db IDB)
func (*RespConnBase) Name ¶
func (c *RespConnBase) Name() (name string)
func (*RespConnBase) SetConnName ¶
func (c *RespConnBase) SetConnName(name string)
func (*RespConnBase) SetDb ¶
func (c *RespConnBase) SetDb(db IDB)
func (*RespConnBase) SetStorager ¶
func (c *RespConnBase) SetStorager(store IStorager)
func (*RespConnBase) Storager ¶
func (c *RespConnBase) Storager() (store IStorager)
type RespServiceName ¶
type RespServiceName string
type SlotsRestoreObj ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.