proto

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 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 PutMsgBatchAllocator added in v1.3.2

func PutMsgBatchAllocator(mba *MsgBatchAllocator)

PutMsgBatchAllocator all the resource back into 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 Executor added in v1.3.2

type Executor interface {
	Execute(mba *MsgBatchAllocator, msgs []*Message) error
	Close() error
}

Executor is the interface for backend run and process the messages.

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) 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) WithError added in v1.3.2

func (m *Message) WithError(err error)

WithError with error.

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 NewMsgBatch

func NewMsgBatch() *MsgBatch

NewMsgBatch will get msg from pool

func (*MsgBatch) AddMsg

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

AddMsg will add new message reference to the buffer

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(cluster, addr string)

Done will set done and report prom HandleTime.

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 position, if not, nil will be return

func (*MsgBatch) Reset

func (m *MsgBatch) Reset()

Reset will reset all the field as initial value but msgs

type MsgBatchAllocator added in v1.3.2

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

MsgBatchAllocator will manage and allocate the msg batches

func GetMsgBatchAllocator added in v1.3.2

func GetMsgBatchAllocator() *MsgBatchAllocator

GetMsgBatchAllocator get mb batch allocate.

func (*MsgBatchAllocator) Add added in v1.3.2

func (m *MsgBatchAllocator) Add(delta int)

Add adds delta, which may be negative, to the WaitGroup counter.

func (*MsgBatchAllocator) AddMsg added in v1.3.2

func (m *MsgBatchAllocator) AddMsg(node string, msg *Message)

AddMsg will add new msg and create a new batch if node not exists.

func (*MsgBatchAllocator) MsgBatchs added in v1.3.2

func (m *MsgBatchAllocator) MsgBatchs() map[string]*MsgBatch

MsgBatchs will return the self mbMap for iterator

func (*MsgBatchAllocator) Reset added in v1.3.2

func (m *MsgBatchAllocator) Reset()

Reset inner MsgBatchs

func (*MsgBatchAllocator) Wait added in v1.3.2

func (m *MsgBatchAllocator) 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
	Close() error
}

NodeConn handle Msg to backend cache server and read response.

type Pinger added in v1.3.2

type Pinger interface {
	Ping() error
	Close() error
}

Pinger for executor ping node.

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