Documentation
¶
Overview ¶
对应RedisClient结构体, 及相应的功能
Index ¶
Constants ¶
View Source
const MaxSlotNum = models.DEFAULT_SLOT_NUM
Variables ¶
View Source
var ( ErrBadRespType = errors.New("bad resp type for command") ErrBadOpStrLen = errors.New("bad command length, too short or too long") )
View Source
var ErrFailedRequest = errors.New("discard failed request")
View Source
var ErrRespIsRequired = errors.New("resp is required")
View Source
var ErrSlotIsNotReady = errors.New("slot is not ready, may be offline")
Functions ¶
Types ¶
type BackendConn ¶
type BackendConn struct {
// contains filtered or unexported fields
}
如何实现的读写分离及 Request & Response 匹配的?
func NewBackendConn ¶
func NewBackendConn(addr, auth string) *BackendConn
func (*BackendConn) Addr ¶
func (bc *BackendConn) Addr() string
func (*BackendConn) Close ¶
func (bc *BackendConn) Close()
func (*BackendConn) PushBack ¶
func (bc *BackendConn) PushBack(r *Request)
func (*BackendConn) Run ¶
func (bc *BackendConn) Run()
type Dispatcher ¶
type FlushPolicy ¶
type FlushPolicy struct {
*redis.Encoder
MaxBuffered int
MaxInterval int64
// contains filtered or unexported fields
}
func (*FlushPolicy) Flush ¶
func (p *FlushPolicy) Flush(force bool) error
type OpStats ¶
type OpStats struct {
// contains filtered or unexported fields
}
func GetAllOpStats ¶
func GetAllOpStats() []*OpStats
func GetOpStats ¶
func (*OpStats) MarshalJSON ¶
type Request ¶
type Request struct {
// 原始的请求串?
OpStr string
// 请求开始的时间戳?
Start int64
// 解析后的请求?
Resp *redis.Resp
Coalesce func() error
// 处理结果
Response struct {
Resp *redis.Resp
Err error
}
// 这两个的区别?
// future锁, writer 使用 r.Wait.Wait() 等待处理的结束.
// 对象构造的时候会初始化, 见session.go handleRequest()
Wait *sync.WaitGroup
Failed *atomic2.Bool
// contains filtered or unexported fields
}
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
slot-id -> slot-object
func NewWithAuth ¶
type Session ¶
type Session struct {
*redis.Conn
Ops int64
// 上一条指令开始处理的时间
LastOpUnix int64
// 连接建立的时间
CreateUnix int64
// contains filtered or unexported fields
}
func NewSessionSize ¶
func (*Session) Serve ¶
func (s *Session) Serve(d Dispatcher, maxPipeline int)
每个 client session 的伺服, goroutine 请求转发给后端都是在loopReader里处理的, loopWriter只是等待指令结果然后写回客户端
type SharedBackendConn ¶
type SharedBackendConn struct {
// contains filtered or unexported fields
}
func NewSharedBackendConn ¶
func NewSharedBackendConn(addr, auth string) *SharedBackendConn
func (*SharedBackendConn) Close ¶
func (s *SharedBackendConn) Close() bool
func (*SharedBackendConn) IncrRefcnt ¶
func (s *SharedBackendConn) IncrRefcnt()
Click to show internal directories.
Click to hide internal directories.