resp

package
v0.0.0-...-70285c8 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRespType     = errors.New("bad resp type")
	ErrBadRespEnd      = errors.New("bad resp end")
	ErrBadRespInt      = errors.New("bad resp int")
	ErrBadRespBytesLen = errors.New("bad resp bytes len")
	ErrBadRespArrayLen = errors.New("bad resp array len")
)

Functions

func Encode

func Encode(w *bufio.Writer, r Resp) error

func EncodeToBytes

func EncodeToBytes(r Resp) ([]byte, error)

func EncodeToString

func EncodeToString(r Resp) (string, error)

func MustEncode

func MustEncode(w *bufio.Writer, r Resp)

func MustEncodeToBytes

func MustEncodeToBytes(r Resp) []byte

func ParseArgs

func ParseArgs(resp Resp) (cmd string, args [][]byte, err error)

Types

type Array

type Array struct {
	Value []Resp
}

func NewArray

func NewArray() *Array

func (*Array) Append

func (r *Array) Append(a Resp)

func (*Array) AppendBulkBytes

func (r *Array) AppendBulkBytes(b []byte)

func (*Array) AppendError

func (r *Array) AppendError(err error)

func (*Array) AppendInt

func (r *Array) AppendInt(n int64)

func (*Array) AppendString

func (r *Array) AppendString(s string)

func (*Array) Type

func (r *Array) Type() RespType

type BulkBytes

type BulkBytes struct {
	Value []byte
}

func NewBulkBytes

func NewBulkBytes(p []byte) *BulkBytes

func NewBulkBytesWithString

func NewBulkBytesWithString(s string) *BulkBytes

func (*BulkBytes) Type

func (r *BulkBytes) Type() RespType

type Error

type Error struct {
	Value string
}

func NewError

func NewError(err error) *Error

func NewErrorWithString

func NewErrorWithString(s string) *Error

func (*Error) Type

func (r *Error) Type() RespType

type Int

type Int struct {
	Value int64
}

func NewInt

func NewInt(n int64) *Int

func (*Int) Type

func (r *Int) Type() RespType

type Ping

type Ping byte

func NewPing

func NewPing() Ping

func (Ping) Type

func (r Ping) Type() RespType

type Resp

type Resp interface {
	Type() RespType
}

func Decode

func Decode(r *bufio.Reader) (Resp, error)

func DecodeFromBytes

func DecodeFromBytes(p []byte) (Resp, error)

func DecodeRequest

func DecodeRequest(r *bufio.Reader) (Resp, error)

Decode RESP Request, return must be array type or ping type

func DecodeRequestFromBytes

func DecodeRequestFromBytes(p []byte) (Resp, error)

func MustDecode

func MustDecode(r *bufio.Reader) Resp

func MustDecodeFromBytes

func MustDecodeFromBytes(p []byte) Resp

func NewRequest

func NewRequest(cmd string, args ...interface{}) Resp

RESP Request is a array of bulk strings.

type RespType

type RespType byte
const (
	TypeString    RespType = '+'
	TypeError     RespType = '-'
	TypeInt       RespType = ':'
	TypeBulkBytes RespType = '$'
	TypeArray     RespType = '*'
	TypePing      RespType = '\n'
)

func (RespType) String

func (t RespType) String() string

type String

type String struct {
	Value string
}

func NewString

func NewString(s string) *String

func (*String) Type

func (r *String) Type() RespType

Jump to

Keyboard shortcuts

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