proto

package
v0.0.0-...-16416bd Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

errors

Functions

This section is empty.

Types

type CacheType

type CacheType string

CacheType memcache or redis

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

Cache type: memcache or redis.

type Decoder

type Decoder interface {
	Decode() (*Request, error)
}

Decoder decode bytes from client.

type Encoder

type Encoder interface {
	Encode(*Response) error
}

Encoder encode response.

type Handler

type Handler interface {
	Handle(*Request) (*Response, error)
}

Handler handle request to backend cache server and read response.

type Pinger

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

Pinger ping node connection.

type Request

type Request struct {
	Type CacheType

	Resp *Response
	// contains filtered or unexported fields
}

Request read from client.

func ErrRequest

func ErrRequest() *Request

ErrRequest return err request.

func (*Request) Batch

func (r *Request) Batch() ([]Request, *Response)

Batch returns sub request if is batch.

func (*Request) BatchWait

func (r *Request) BatchWait()

BatchWait blocks until the all sub request done.

func (*Request) Cmd

func (r *Request) Cmd() string

Cmd returns proto request cmd.

func (*Request) Done

func (r *Request) Done(resp *Response)

Done done.

func (*Request) DoneWithError

func (r *Request) DoneWithError(err error)

DoneWithError done with error.

func (*Request) IsBatch

func (r *Request) IsBatch() bool

IsBatch returns whether or not batch.

func (*Request) Key

func (r *Request) Key() []byte

Key returns proto request key.

func (*Request) Process

func (r *Request) Process()

Process means request processing.

func (*Request) Proto

func (r *Request) Proto() protoRequest

Proto returns proto request.

func (*Request) Since

func (r *Request) Since() time.Duration

Since returns the time elapsed since t.

func (*Request) Wait

func (r *Request) Wait()

Wait wait group.

func (*Request) WithProto

func (r *Request) WithProto(proto protoRequest)

WithProto with proto request.

type RequestChan

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

RequestChan is queue be used process request.

func NewRequestChan

func NewRequestChan() *RequestChan

NewRequestChan new request chan, defalut buffer 128.

func NewRequestChanBuffer

func NewRequestChanBuffer(n int) *RequestChan

NewRequestChanBuffer new request chan with buffer.

func (*RequestChan) Buffered

func (c *RequestChan) Buffered() int

Buffered returns buffer.

func (*RequestChan) Close

func (c *RequestChan) Close()

Close close request chan.

func (*RequestChan) Closed

func (c *RequestChan) Closed() bool

Closed return closed.

func (*RequestChan) PopFront

func (c *RequestChan) PopFront() (*Request, bool)

PopFront pop front from queue.

func (*RequestChan) PushBack

func (c *RequestChan) PushBack(r *Request) int

PushBack push request back queue.

type Response

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

Response read from cache server.

func (*Response) Err

func (r *Response) Err() error

Err returns error.

func (*Response) Merge

func (r *Response) Merge(subs []Request)

Merge merges subs response into self.

func (*Response) Proto

func (r *Response) Proto() protoResponse

Proto returns proto response.

func (*Response) WithError

func (r *Response) WithError(err error)

WithError with error.

func (*Response) WithProto

func (r *Response) WithProto(proto protoResponse)

WithProto with proto response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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