proto

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSupportCacheType = errs.New("unsupported cache type")
)

errors

Functions

func PutMsgBatchs

func PutMsgBatchs(mbs []*MsgBatch)

PutMsgBatchs put MsgBatchs into recycle using pool.

func PutMsgs

func PutMsgs(msgs []*Message)

PutMsgs Release message.

Types

type CacheType

type CacheType string

CacheType memcache or redis

const (
	CacheTypeUnknown        CacheType = "unknown"
	CacheTypeMemcache       CacheType = "memcache"
	CacheTypeMemcacheBinary CacheType = "memcache_binary"
	CacheTypeRedis          CacheType = "redis"
)

Cache type: memcache or redis.

type Message

type Message struct {
	Type CacheType
	// contains filtered or unexported fields
}

Message read from client.

func ErrMessage

func ErrMessage(err error) *Message

ErrMessage return err Msg.

func GetMsgs

func GetMsgs(n int, caps ...int) []*Message

GetMsgs alloc a slice to the message

func NewMessage

func NewMessage() *Message

NewMessage will create new message object. this will be used be sub msg req.

func (*Message) Batch

func (m *Message) Batch() []*Message

Batch returns sub Msg if is batch.

func (*Message) DoneWithError

func (m *Message) DoneWithError(err error)

DoneWithError done with error.

func (*Message) Err

func (m *Message) Err() error

Err returns error.

func (*Message) IsBatch

func (m *Message) IsBatch() bool

IsBatch returns whether or not batch.

func (*Message) MarkEnd

func (m *Message) MarkEnd()

MarkEnd will set the end time of the command to now.

func (*Message) MarkRead

func (m *Message) MarkRead()

MarkRead will set the read time of the command to now.

func (*Message) MarkStart

func (m *Message) MarkStart()

MarkStart will set the start time of the command to now.

func (*Message) MarkWrite

func (m *Message) MarkWrite()

MarkWrite will set the write time of the command to now.

func (*Message) NextReq

func (m *Message) NextReq() (req Request)

NextReq will iterator itself until nil.

func (*Message) RemoteDur

func (m *Message) RemoteDur() time.Duration

RemoteDur will return the remote execute time of remote mc node.

func (*Message) Request

func (m *Message) Request() Request

Request returns proto Msg.

func (*Message) Requests

func (m *Message) Requests() []Request

Requests return all request.

func (*Message) Reset

func (m *Message) Reset()

Reset will clean the msg

func (*Message) ResetSubs

func (m *Message) ResetSubs()

ResetSubs will return the Msg data to flush and reset

func (*Message) TotalDur

func (m *Message) TotalDur() time.Duration

TotalDur will return the total duration of a command.

func (*Message) WithRequest

func (m *Message) WithRequest(req Request)

WithRequest with proto request.

type MsgBatch

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

MsgBatch is a single execute unit

func GetMsgBatchs

func GetMsgBatchs(n int) []*MsgBatch

GetMsgBatchs returns new slice of msgs

func NewMsgBatch

func NewMsgBatch() *MsgBatch

NewMsgBatch will get msg from pool

func (*MsgBatch) Add

func (m *MsgBatch) Add(n int)

Add adds n for WaitGroup

func (*MsgBatch) AddMsg

func (m *MsgBatch) AddMsg(msg *Message)

AddMsg will add new message reference to the buffer

func (*MsgBatch) BatchDone

func (m *MsgBatch) BatchDone(cluster, addr string)

BatchDone will set done and report prom HandleTime.

func (*MsgBatch) BatchDoneWithError

func (m *MsgBatch) BatchDoneWithError(cluster, addr string, err error)

BatchDoneWithError will set done with error and report prom ErrIncr.

func (*MsgBatch) Buffer

func (m *MsgBatch) Buffer() *bufio.Buffer

Buffer will send back buffer to executor

func (*MsgBatch) Count

func (m *MsgBatch) Count() int

Count returns the count of the batch size

func (*MsgBatch) Done

func (m *MsgBatch) Done()

Done will set the total batch to done and notify the handler to check it.

func (*MsgBatch) Msgs

func (m *MsgBatch) Msgs() []*Message

Msgs returns a slice of Msg

func (*MsgBatch) Nth

func (m *MsgBatch) Nth(i int) *Message

Nth will get the given positon, if not , nil will be return

func (*MsgBatch) Reset

func (m *MsgBatch) Reset()

Reset will reset all the field as initial value but msgs

func (*MsgBatch) Wait

func (m *MsgBatch) Wait()

Wait waits until all the message was done

type MsgChan

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

MsgChan is queue be used process Msg.

func NewMsgChan

func NewMsgChan() *MsgChan

NewMsgChan new Msg chan, defalut buffer 128.

func NewMsgChanBuffer

func NewMsgChanBuffer(n int) *MsgChan

NewMsgChanBuffer new Msg chan with buffer.

func (*MsgChan) Buffered

func (c *MsgChan) Buffered() int

Buffered returns buffer.

func (*MsgChan) Close

func (c *MsgChan) Close()

Close close Msg chan.

func (*MsgChan) Closed

func (c *MsgChan) Closed() bool

Closed return closed.

func (*MsgChan) PopFront

func (c *MsgChan) PopFront() (*Message, bool)

PopFront pop front from queue.

func (*MsgChan) PushBack

func (c *MsgChan) PushBack(r *Message) int

PushBack push Msg back queue.

type NodeConn

type NodeConn interface {
	WriteBatch(*MsgBatch) error
	ReadBatch(*MsgBatch) error

	Ping() error
	Close() error
}

NodeConn handle Msg to backend cache server and read response.

type ProxyConn

type ProxyConn interface {
	Decode([]*Message) ([]*Message, error)
	Encode(msg *Message) error
	Flush() error
}

ProxyConn decode bytes from client and encode write to conn.

type Request

type Request interface {
	CmdString() string
	Cmd() []byte
	Key() []byte
	Put()
}

Request request interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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