resp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrInvalidProtocol indicates a wrong protocol format
	ErrInvalidProtocol = errors.New("invalid protocol")
)

Functions

func ReadArray

func ReadArray(r io.Reader) (int, error)

ReadArray reads an array

func ReadBulkString

func ReadBulkString(r io.Reader) (string, error)

ReadBulkString reads a bulkstring

func ReadError

func ReadError(r io.Reader) (string, error)

ReadError reads an error

func ReadInteger

func ReadInteger(r io.Reader) (int64, error)

ReadInteger reads a integer

func ReadSimpleString

func ReadSimpleString(r io.Reader) (string, error)

ReadSimpleString reads a simplestring

func ReplyBulkString

func ReplyBulkString(w io.Writer, msg string) error

ReplyBulkString replies a bulkstring

func ReplyError

func ReplyError(w io.Writer, msg string) error

ReplyError replies an error

func ReplyInteger

func ReplyInteger(w io.Writer, val int64) error

ReplyInteger replies an integer

func ReplyNullBulkString

func ReplyNullBulkString(w io.Writer) error

ReplyNullBulkString replies a null bulkstring

func ReplySimpleString

func ReplySimpleString(w io.Writer, msg string) error

ReplySimpleString replies a simplestring

Types

type Decoder

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

Decoder implements the decoder interface

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a RESP decoder

func (*Decoder) Array

func (r *Decoder) Array() (int, error)

Array parses a RESP array

func (*Decoder) BulkString

func (r *Decoder) BulkString() (string, error)

BulkString parses a RESP bulkstring

func (*Decoder) Error

func (r *Decoder) Error() (string, error)

Error parses a RESP error

func (*Decoder) Integer

func (r *Decoder) Integer() (int64, error)

Integer parses a RESP integer

func (*Decoder) SimpleString

func (r *Decoder) SimpleString() (string, error)

SimpleString parses a RESP simplestring

type Encoder

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

Encoder implements the Encoder interface

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder creates a RESP encoder

func ReplyArray

func ReplyArray(w io.Writer, size int) (*Encoder, error)

ReplyArray replies an array

func (*Encoder) Array

func (r *Encoder) Array(size int) error

Array builds a RESP array

func (*Encoder) BulkString

func (r *Encoder) BulkString(s string) error

BulkString builds a RESP bulkstring

func (*Encoder) Error

func (r *Encoder) Error(s string) error

Error builds a RESP error

func (*Encoder) Integer

func (r *Encoder) Integer(v int64) error

Integer builds a RESP integer

func (*Encoder) NullBulkString

func (r *Encoder) NullBulkString() error

NullBulkString builds a RESP null bulkstring

func (*Encoder) SimpleString

func (r *Encoder) SimpleString(s string) error

SimpleString builds a RESP simplestring

type Reader

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

Reader implements a reader which supports reading to a delimer

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read bytes into p

func (*Reader) ReadBytes

func (r *Reader) ReadBytes(delim byte) ([]byte, error)

ReadBytes read bytes until delim, it read byte by byte and do not buffer anything, you should use a buffer reader as the backend to achieve performance

Jump to

Keyboard shortcuts

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