Documentation ¶
Index ¶
- Constants
- Variables
- func APIRequest(method string, endpoint string, body io.Reader, timeout time.Duration, ...) (int, error)
- func BuildCommand(args [][]byte) redcon.Command
- func CutNamesapce(rawKey []byte) ([]byte, error)
- func Decorate(f APIHandler, ds ...Decorator) httprouter.Handle
- func DeepCopyCmd(cmd redcon.Command) redcon.Command
- func DumpDynamicConf() []string
- func ExtractNamesapce(rawKey []byte) (string, []byte, error)
- func ExtractTable(rawKey []byte) ([]byte, []byte, error)
- func GetIPv4ForInterfaceName(ifname string) string
- func GetIntDynamicConf(k string) int
- func GetNamespaceAndPartition(fullNamespace string) (string, int)
- func GetNsDesp(ns string, part int) string
- func GetStrDynamicConf(k string) string
- func InitDefaultForGLogger(dir string)
- func IsConfSetted(k string) bool
- func IsFullScanCommand(cmd string) bool
- func IsInternalTableName(tb string) bool
- func IsMergeCommand(cmd string) bool
- func IsMergeIndexSearchCommand(cmd string) bool
- func IsMergeKeysCommand(cmd string) bool
- func IsMergeScanCommand(cmd string) bool
- func IsRoleLogSyncer(role string) bool
- func IsValidNamespaceName(ns string) bool
- func NewDeadlineTransport(timeout time.Duration) *http.Transport
- func NewDefaultLogger(module string) *defaultLogger
- func NewGLogger() *gLogger
- func RegisterConfChangedHandler(key string, h KeyChangedHandler)
- func RespondV1(w http.ResponseWriter, code int, data interface{})
- func RunFileSync(remote string, srcPath string, dstPath string, stopCh chan struct{}) error
- func SetIntDynamicConf(k string, newV int)
- func SetRsyncLimit(limit int64)
- func SetStrDynamicConf(k string, newV string)
- func VerString(app string) string
- type APIHandler
- type CmdRouter
- func (r *CmdRouter) GetCmdHandler(name string) (CommandFunc, bool)
- func (r *CmdRouter) GetMergeCmdHandler(name string) (MergeCommandFunc, bool, bool)
- func (r *CmdRouter) GetWCmdHandler(name string) (WriteCommandFunc, bool)
- func (r *CmdRouter) RegisterMerge(name string, f MergeCommandFunc) bool
- func (r *CmdRouter) RegisterRead(name string, f CommandFunc) bool
- func (r *CmdRouter) RegisterWrite(name string, f WriteCommandFunc) bool
- func (r *CmdRouter) RegisterWriteMerge(name string, f MergeCommandFunc) bool
- type CommandFunc
- type CommandRspFunc
- type DataType
- type DataVersionT
- type Decorator
- type ExpirationPolicy
- type ExpiredDataBuffer
- type FieldPair
- type FullScanResult
- type HIndexRespWithValues
- type HsetIndexSchema
- type HttpErr
- type IClusterInfo
- type IndexPropertyDType
- type IndexSchema
- type IndexState
- type InternalCommandFunc
- type JSONIndexSchema
- type KFVals
- type KVRecord
- type KVRecordRet
- type KVals
- type KeyChangedHandler
- type LevelLogger
- func (ll *LevelLogger) Debug(args ...interface{})
- func (ll *LevelLogger) DebugDepth(d int, l string)
- func (ll *LevelLogger) Debugf(f string, args ...interface{})
- func (ll *LevelLogger) Error(args ...interface{})
- func (ll *LevelLogger) ErrorDepth(d int, l string)
- func (ll *LevelLogger) Errorf(f string, args ...interface{})
- func (ll *LevelLogger) Fatal(args ...interface{})
- func (ll *LevelLogger) Fatalf(f string, args ...interface{})
- func (ll *LevelLogger) Info(args ...interface{})
- func (ll *LevelLogger) InfoDepth(d int, l string)
- func (ll *LevelLogger) Infof(f string, args ...interface{})
- func (ll *LevelLogger) Level() int32
- func (ll *LevelLogger) Panic(args ...interface{})
- func (ll *LevelLogger) Panicf(f string, args ...interface{})
- func (ll *LevelLogger) SetLevel(l int32)
- func (ll *LevelLogger) Warning(args ...interface{})
- func (ll *LevelLogger) Warningf(f string, args ...interface{})
- type Logger
- type MemberInfo
- type MergeCommandFunc
- type MergeLogger
- func (l *MergeLogger) MergeError(entries ...interface{})
- func (l *MergeLogger) MergeErrorf(format string, args ...interface{})
- func (l *MergeLogger) MergeInfo(entries ...interface{})
- func (l *MergeLogger) MergeInfof(format string, args ...interface{})
- func (l *MergeLogger) MergeWarning(entries ...interface{})
- func (l *MergeLogger) MergeWarningf(format string, args ...interface{})
- type MergeWriteCommandFunc
- type SMCmdRouter
- type ScanResult
- type ScorePair
- type SearchResultHeap
- type SnapshotSyncInfo
- type StoppableListener
- type StringArray
- type WriteCmd
- type WriteCommandFunc
Constants ¶
const ( ConfCheckSnapTimeout = "check_snap_timeout" ConfCheckRaftTimeout = "check_raft_timeout" ConfIgnoreStartupNoBackup = "ignore_startup_nobackup" ConfIgnoreRemoteFileSync = "ignore_remote_file_sync" ConfMaxRemoteRecover = "max_remote_recover" ConfSlowLimiterSwitch = "slow_limiter_switch" ConfSlowLimiterRefuseCostMs = "slow_limiter_refuse_cost_ms" ConfSlowLimiterHalfOpenSec = "slow_limiter_half_open_sec" )
const ( LOG_ERR int32 = iota LOG_WARN LOG_INFO LOG_DEBUG LOG_DETAIL )
const ( DIR_PERM = 0755 FILE_PERM = 0644 )
const ( LearnerRoleLogSyncer = "role_log_syncer" LearnerRoleSearcher = "role_searcher" )
const ( KVName = "KV" ListName = "LIST" HashName = "HASH" SetName = "SET" ZSetName = "ZSET" )
const ( DefaultExpirationPolicy = "local_deletion" WaitCompactExpirationPolicy = "wait_compact" )
const ( RangeClose uint8 = 0x00 RangeLOpen uint8 = 0x01 RangeROpen uint8 = 0x10 RangeOpen uint8 = 0x11 )
const ( MAX_PARTITION_NUM = 1024 MAX_REPLICATOR = 5 )
const ( // api used by data node APIAddNode = "/cluster/node/add" APIAddLearnerNode = "/cluster/node/addlearner" APIRemoveNode = "/cluster/node/remove" APIGetMembers = "/cluster/members" APIGetLeader = "/cluster/leader" APICheckBackup = "/cluster/checkbackup" APIGetIndexes = "/schema/indexes" APINodeAllReady = "/node/allready" // check if the namespace raft node is synced and can be elected as leader immediately APIIsRaftSynced = "/cluster/israftsynced" APITableStats = "/tablestats" // below api for pd APIGetSnapshotSyncInfo = "/pd/snapshot_sync_info" )
const (
InternalPrefix = "##"
)
const (
KEYSEP = byte(':')
)
const (
NamespaceTableSeperator = byte(':')
)
const (
SnapWaitTimeout = time.Minute * 20
)
const (
ValueHeaderV1Str = "value_header_v1"
)
Variables ¶
var ( VerBinary = "unset" BuildTime = "unset" Commit = "unset" )
var ( SCAN_CURSOR_SEP = []byte(";") SCAN_NODE_SEP = []byte(":") )
var ( ErrInvalidCommand = errors.New("invalid command") ErrStopped = errors.New("the node stopped") ErrQueueTimeout = errors.New("queue request timeout") ErrInvalidArgs = errors.New("invalid arguments") ErrInvalidRedisKey = errors.New("invalid redis key") ErrInvalidScanType = errors.New("invalid scan type") ErrEpochMismatch = errors.New("epoch mismatch") ErrInvalidTableName = errors.New("table name is invalid") ErrInvalidScanCursor = errors.New("invalid scan cursor") ErrScanCursorNoTable = errors.New("scan cursor must has table") ErrUnexpectError = errors.New("unexpected error") ErrInvalidPrefix = errors.New("invalid prefix") ErrNotSupport = errors.New("not supported") )
var ( DefaultSnapCount = 400000 DefaultSnapCatchup = 300000 )
var ( MAX_BATCH_NUM = 5000 MinScore float64 = math.Inf(-1) MaxScore float64 = math.Inf(1) InvalidScore int64 = -1 << 63 MAX_SCAN_JOB = 10 )
var (
ErrDeprecatedAPI = errors.New("deprecated api")
)
var ErrRsyncFailed = errors.New("transfer snapshot failed due to rsync error")
var ErrTransferOutofdate = errors.New("waiting transfer snapshot too long, maybe out of date")
Functions ¶
func APIRequest ¶
func APIRequest(method string, endpoint string, body io.Reader, timeout time.Duration, ret interface{}) (int, error)
stores the result in the value pointed to by ret(must be a pointer)
func BuildCommand ¶ added in v0.7.1
func CutNamesapce ¶ added in v0.7.1
func Decorate ¶
func Decorate(f APIHandler, ds ...Decorator) httprouter.Handle
func DumpDynamicConf ¶ added in v0.6.2
func DumpDynamicConf() []string
func GetIPv4ForInterfaceName ¶
func GetIntDynamicConf ¶ added in v0.6.2
func GetStrDynamicConf ¶ added in v0.6.2
func InitDefaultForGLogger ¶ added in v0.8.1
func InitDefaultForGLogger(dir string)
should call once at the app entrance after flag parsed
func IsConfSetted ¶ added in v0.6.2
func IsFullScanCommand ¶
func IsInternalTableName ¶
func IsMergeCommand ¶
func IsMergeKeysCommand ¶
func IsMergeScanCommand ¶
func IsRoleLogSyncer ¶ added in v0.6.2
func IsValidNamespaceName ¶
func NewDefaultLogger ¶
func NewDefaultLogger(module string) *defaultLogger
func NewGLogger ¶ added in v0.8.1
func NewGLogger() *gLogger
func RegisterConfChangedHandler ¶ added in v0.8.2
func RegisterConfChangedHandler(key string, h KeyChangedHandler)
func RespondV1 ¶
func RespondV1(w http.ResponseWriter, code int, data interface{})
func RunFileSync ¶
make sure the file sync will not overwrite hard link file inplace. (Because the hard link file content which may be used in rocksdb should not be changed ) So with hard link sync, we make sure we do unlink on the file before we update it. (rsync just do it)
func SetIntDynamicConf ¶ added in v0.6.2
func SetRsyncLimit ¶ added in v0.4.3
func SetRsyncLimit(limit int64)
func SetStrDynamicConf ¶ added in v0.6.2
Types ¶
type APIHandler ¶
type APIHandler func(http.ResponseWriter, *http.Request, httprouter.Params) (interface{}, error)
func PlainText ¶
func PlainText(f APIHandler) APIHandler
func V1 ¶
func V1(f APIHandler) APIHandler
type CmdRouter ¶
type CmdRouter struct {
// contains filtered or unexported fields
}
func NewCmdRouter ¶
func NewCmdRouter() *CmdRouter
func (*CmdRouter) GetCmdHandler ¶
func (r *CmdRouter) GetCmdHandler(name string) (CommandFunc, bool)
func (*CmdRouter) GetMergeCmdHandler ¶
func (r *CmdRouter) GetMergeCmdHandler(name string) (MergeCommandFunc, bool, bool)
return handler, iswrite, isexist
func (*CmdRouter) GetWCmdHandler ¶ added in v0.8.0
func (r *CmdRouter) GetWCmdHandler(name string) (WriteCommandFunc, bool)
func (*CmdRouter) RegisterMerge ¶
func (r *CmdRouter) RegisterMerge(name string, f MergeCommandFunc) bool
func (*CmdRouter) RegisterRead ¶ added in v0.8.0
func (r *CmdRouter) RegisterRead(name string, f CommandFunc) bool
func (*CmdRouter) RegisterWrite ¶ added in v0.8.0
func (r *CmdRouter) RegisterWrite(name string, f WriteCommandFunc) bool
func (*CmdRouter) RegisterWriteMerge ¶
func (r *CmdRouter) RegisterWriteMerge(name string, f MergeCommandFunc) bool
type CommandRspFunc ¶
type DataVersionT ¶ added in v0.8.0
type DataVersionT int
const ( DefaultDataVer DataVersionT = iota //ValueHeaderV1 will add header to kv values to store ttl or other header data ValueHeaderV1 UnknownDataType )
func StringToDataVersionType ¶ added in v0.8.0
func StringToDataVersionType(s string) (DataVersionT, error)
type Decorator ¶
type Decorator func(APIHandler) APIHandler
func HttpLog ¶
func HttpLog(log *LevelLogger, level int32) Decorator
type ExpirationPolicy ¶
type ExpirationPolicy byte
const ( // LocalDeletion indicates the expired data would be deleted by the underlying storage system automatically and the logical layer // do not need to care about the data expiration. Every node in the cluster should start the 'TTLChecker' of the storage system // with this policy. LocalDeletion ExpirationPolicy = iota // PeriodicalRotation // WaitCompact indicates that all ttl will be stored in the values and will be checked while compacting and reading WaitCompact UnknownPolicy )
func StringToExpirationPolicy ¶
func StringToExpirationPolicy(s string) (ExpirationPolicy, error)
type ExpiredDataBuffer ¶
type FullScanResult ¶
type HIndexRespWithValues ¶
type HsetIndexSchema ¶
type HsetIndexSchema struct { Name string `json:"name"` IndexField string `json:"index_field"` PrefixLen int32 `json:"prefix_len"` Unique int32 `json:"unique"` ValueType IndexPropertyDType `json:"value_type"` State IndexState `json:"state"` }
func (*HsetIndexSchema) IsValidNewSchema ¶
func (s *HsetIndexSchema) IsValidNewSchema() bool
type IClusterInfo ¶
type IndexPropertyDType ¶
type IndexPropertyDType int32
const ( Int64V IndexPropertyDType = 0 Int32V IndexPropertyDType = 1 StringV IndexPropertyDType = 2 MaxVT IndexPropertyDType = 3 )
type IndexSchema ¶
type IndexSchema struct { HsetIndexes []*HsetIndexSchema `json:"hset_indexes"` JSONIndexes []*JSONIndexSchema `json:"json_indexes"` }
type IndexState ¶
type IndexState int32
const ( InitIndex IndexState = 0 BuildingIndex IndexState = 1 BuildDoneIndex IndexState = 2 ReadyIndex IndexState = 3 DeletedIndex IndexState = 4 MaxIndexState IndexState = 5 )
type InternalCommandFunc ¶
type JSONIndexSchema ¶
type JSONIndexSchema struct {
State IndexState `json:"state"`
}
type KFVals ¶
type KFVals struct { PK []byte Vals []KVRecordRet }
type KVRecordRet ¶
type KeyChangedHandler ¶ added in v0.8.2
type KeyChangedHandler func(newV interface{})
type LevelLogger ¶
type LevelLogger struct { Logger Logger // contains filtered or unexported fields }
func NewLevelLogger ¶
func NewLevelLogger(level int32, l Logger) *LevelLogger
func (*LevelLogger) Debug ¶
func (ll *LevelLogger) Debug(args ...interface{})
func (*LevelLogger) DebugDepth ¶
func (ll *LevelLogger) DebugDepth(d int, l string)
func (*LevelLogger) Debugf ¶
func (ll *LevelLogger) Debugf(f string, args ...interface{})
func (*LevelLogger) Error ¶
func (ll *LevelLogger) Error(args ...interface{})
func (*LevelLogger) ErrorDepth ¶
func (ll *LevelLogger) ErrorDepth(d int, l string)
func (*LevelLogger) Errorf ¶
func (ll *LevelLogger) Errorf(f string, args ...interface{})
func (*LevelLogger) Fatal ¶
func (ll *LevelLogger) Fatal(args ...interface{})
func (*LevelLogger) Fatalf ¶
func (ll *LevelLogger) Fatalf(f string, args ...interface{})
func (*LevelLogger) Info ¶
func (ll *LevelLogger) Info(args ...interface{})
func (*LevelLogger) InfoDepth ¶
func (ll *LevelLogger) InfoDepth(d int, l string)
func (*LevelLogger) Infof ¶
func (ll *LevelLogger) Infof(f string, args ...interface{})
func (*LevelLogger) Level ¶
func (ll *LevelLogger) Level() int32
func (*LevelLogger) Panic ¶
func (ll *LevelLogger) Panic(args ...interface{})
func (*LevelLogger) Panicf ¶
func (ll *LevelLogger) Panicf(f string, args ...interface{})
func (*LevelLogger) SetLevel ¶
func (ll *LevelLogger) SetLevel(l int32)
func (*LevelLogger) Warning ¶
func (ll *LevelLogger) Warning(args ...interface{})
func (*LevelLogger) Warningf ¶
func (ll *LevelLogger) Warningf(f string, args ...interface{})
type MemberInfo ¶
type MemberInfo struct { // the replica id ID uint64 `json:"id"` // the node id replica belong NodeID uint64 `json:"node_id"` GroupName string `json:"group_name"` // group id the replica belong (different from namespace) GroupID uint64 `json:"group_id"` RaftURLs []string `json:"peer_urls"` }
func (*MemberInfo) IsEqual ¶
func (self *MemberInfo) IsEqual(other *MemberInfo) bool
type MergeCommandFunc ¶
type MergeLogger ¶
type MergeLogger struct { *LevelLogger // contains filtered or unexported fields }
MergeLogger supports merge logging, which merges repeated log lines and prints summary log lines instead.
For merge logging, MergeLogger prints out the line when the line appears at the first time. MergeLogger holds the same log line printed within defaultMergePeriod, and prints out summary log line at the end of defaultMergePeriod. It stops merging when the line doesn't appear within the defaultMergePeriod.
func NewMergeLogger ¶
func NewMergeLogger(logger *LevelLogger) *MergeLogger
func (*MergeLogger) MergeError ¶
func (l *MergeLogger) MergeError(entries ...interface{})
func (*MergeLogger) MergeErrorf ¶
func (l *MergeLogger) MergeErrorf(format string, args ...interface{})
func (*MergeLogger) MergeInfo ¶
func (l *MergeLogger) MergeInfo(entries ...interface{})
func (*MergeLogger) MergeInfof ¶
func (l *MergeLogger) MergeInfof(format string, args ...interface{})
func (*MergeLogger) MergeWarning ¶
func (l *MergeLogger) MergeWarning(entries ...interface{})
func (*MergeLogger) MergeWarningf ¶
func (l *MergeLogger) MergeWarningf(format string, args ...interface{})
type MergeWriteCommandFunc ¶
type SMCmdRouter ¶
type SMCmdRouter struct {
// contains filtered or unexported fields
}
func NewSMCmdRouter ¶
func NewSMCmdRouter() *SMCmdRouter
func (*SMCmdRouter) GetInternalCmdHandler ¶
func (r *SMCmdRouter) GetInternalCmdHandler(name string) (InternalCommandFunc, bool)
func (*SMCmdRouter) RegisterInternal ¶
func (r *SMCmdRouter) RegisterInternal(name string, f InternalCommandFunc) bool
type ScanResult ¶
type SearchResultHeap ¶
type SearchResultHeap []*HIndexRespWithValues
func (SearchResultHeap) Len ¶
func (sh SearchResultHeap) Len() int
func (SearchResultHeap) Less ¶
func (sh SearchResultHeap) Less(i, j int) bool
func (*SearchResultHeap) Pop ¶
func (sh *SearchResultHeap) Pop() interface{}
func (*SearchResultHeap) Push ¶
func (sh *SearchResultHeap) Push(x interface{})
func (SearchResultHeap) Swap ¶
func (sh SearchResultHeap) Swap(i, j int)
type SnapshotSyncInfo ¶
type StoppableListener ¶
type StoppableListener struct { *net.TCPListener // contains filtered or unexported fields }
stoppableListener sets TCP keep-alive timeouts on accepted connections and waits on stopc message
func NewStoppableListener ¶
func NewStoppableListener(addr string, stopc <-chan struct{}) (*StoppableListener, error)
type StringArray ¶
type StringArray []string
func (*StringArray) Set ¶
func (a *StringArray) Set(s string) error
func (*StringArray) String ¶
func (a *StringArray) String() string