resp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2018 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Codec = objconv.Codec{
	NewEmitter: func(w io.Writer) objconv.Emitter { return NewEmitter(w) },
	NewParser:  func(r io.Reader) objconv.Parser { return NewParser(r) },
}

Codec for the RESP format.

Functions

func Marshal

func Marshal(v interface{}) (b []byte, err error)

Marshal writes the RESP representation of v to a byte slice returned in b.

func NewDecoder

func NewDecoder(r io.Reader) *objconv.Decoder

NewDecoder returns a new RESP decoder that parses values from r.

func NewEncoder

func NewEncoder(w io.Writer) *objconv.Encoder

NewEncoder returns a new RESP encoder that writes to w.

func NewStreamDecoder

func NewStreamDecoder(r io.Reader) *objconv.StreamDecoder

NewStreamDecoder returns a new RESP stream decoder that parses values from r.

func NewStreamEncoder

func NewStreamEncoder(w io.Writer) *objconv.StreamEncoder

NewStreamEncoder returns a new RESP stream encoder that writes to w.

func Unmarshal

func Unmarshal(b []byte, v interface{}) error

Unmarshal decodes a RESP representation of v from b.

Types

type ClientEmitter

type ClientEmitter struct {
	Emitter
}

ClientEmitter is the implementation of a RESP emitter suitable to be used for encoding redis client requests.

func NewClientEmitter

func NewClientEmitter(w io.Writer) *ClientEmitter

func (*ClientEmitter) EmitBool

func (e *ClientEmitter) EmitBool(v bool) error

func (*ClientEmitter) EmitDuration

func (e *ClientEmitter) EmitDuration(v time.Duration) error

func (*ClientEmitter) EmitError

func (e *ClientEmitter) EmitError(v error) error

func (*ClientEmitter) EmitFloat

func (e *ClientEmitter) EmitFloat(v float64, bitSize int) error

func (*ClientEmitter) EmitInt

func (e *ClientEmitter) EmitInt(v int64, _ int) error

func (*ClientEmitter) EmitString

func (e *ClientEmitter) EmitString(v string) (err error)

func (*ClientEmitter) EmitTime

func (e *ClientEmitter) EmitTime(v time.Time) error

func (*ClientEmitter) EmitUint

func (e *ClientEmitter) EmitUint(v uint64, _ int) error

type Emitter

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

Emitter implements a RESP emitter that satisfies the objconv.Emitter interface.

func NewEmitter

func NewEmitter(w io.Writer) *Emitter

func (*Emitter) EmitArrayBegin

func (e *Emitter) EmitArrayBegin(n int) (err error)

func (*Emitter) EmitArrayEnd

func (e *Emitter) EmitArrayEnd() (err error)

func (*Emitter) EmitArrayNext

func (e *Emitter) EmitArrayNext() (err error)

func (*Emitter) EmitBool

func (e *Emitter) EmitBool(v bool) (err error)

func (*Emitter) EmitBytes

func (e *Emitter) EmitBytes(v []byte) (err error)

func (*Emitter) EmitDuration

func (e *Emitter) EmitDuration(v time.Duration) (err error)

func (*Emitter) EmitError

func (e *Emitter) EmitError(v error) (err error)

func (*Emitter) EmitFloat

func (e *Emitter) EmitFloat(v float64, bitSize int) (err error)

func (*Emitter) EmitInt

func (e *Emitter) EmitInt(v int64, _ int) (err error)

func (*Emitter) EmitMapBegin

func (e *Emitter) EmitMapBegin(n int) (err error)

func (*Emitter) EmitMapEnd

func (e *Emitter) EmitMapEnd() (err error)

func (*Emitter) EmitMapNext

func (e *Emitter) EmitMapNext() (err error)

func (*Emitter) EmitMapValue

func (e *Emitter) EmitMapValue() (err error)

func (*Emitter) EmitNil

func (e *Emitter) EmitNil() (err error)

func (*Emitter) EmitString

func (e *Emitter) EmitString(v string) (err error)

func (*Emitter) EmitTime

func (e *Emitter) EmitTime(v time.Time) (err error)

func (*Emitter) EmitUint

func (e *Emitter) EmitUint(v uint64, _ int) (err error)

func (*Emitter) Reset

func (e *Emitter) Reset(w io.Writer)

type Error

type Error string

The Error type represents redis errors.

func NewError

func NewError(s string) *Error

NewError returns a new redis error.

func (*Error) Error

func (e *Error) Error() string

Error satsifies the error interface.

func (*Error) Type

func (e *Error) Type() string

Type returns the RESP error type, which is represented by the leading uppercase word in the error string.

type Parser

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

func NewParser

func NewParser(r io.Reader) *Parser

func (*Parser) Buffered

func (p *Parser) Buffered() io.Reader

func (*Parser) ParseArrayBegin

func (p *Parser) ParseArrayBegin() (n int, err error)

func (*Parser) ParseArrayEnd

func (p *Parser) ParseArrayEnd(n int) (err error)

func (*Parser) ParseArrayNext

func (p *Parser) ParseArrayNext(n int) (err error)

func (*Parser) ParseBool

func (p *Parser) ParseBool() (v bool, err error)

func (*Parser) ParseBytes

func (p *Parser) ParseBytes() (v []byte, err error)

func (*Parser) ParseDuration

func (p *Parser) ParseDuration() (v time.Duration, err error)

func (*Parser) ParseError

func (p *Parser) ParseError() (v error, err error)

func (*Parser) ParseFloat

func (p *Parser) ParseFloat() (v float64, err error)

func (*Parser) ParseInt

func (p *Parser) ParseInt() (v int64, err error)

func (*Parser) ParseMapBegin

func (p *Parser) ParseMapBegin() (n int, err error)

func (*Parser) ParseMapEnd

func (p *Parser) ParseMapEnd(n int) (err error)

func (*Parser) ParseMapNext

func (p *Parser) ParseMapNext(n int) (err error)

func (*Parser) ParseMapValue

func (p *Parser) ParseMapValue(n int) (err error)

func (*Parser) ParseNil

func (p *Parser) ParseNil() (err error)

func (*Parser) ParseString

func (p *Parser) ParseString() (v []byte, err error)

func (*Parser) ParseTime

func (p *Parser) ParseTime() (v time.Time, err error)

func (*Parser) ParseType

func (p *Parser) ParseType() (t objconv.Type, err error)

func (*Parser) ParseUint

func (p *Parser) ParseUint() (v uint64, err error)

func (*Parser) Reset

func (p *Parser) Reset(r io.Reader)

Jump to

Keyboard shortcuts

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