Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ProtocolErr = errors.New("RESP protocol error") RecursionLimitErr = errors.New("too many nested RESP arrays") )
Functions ¶
Types ¶
type ParserOptions ¶
type ParserOptions struct {
BulkCaptureLimit int
}
type RespParser ¶
type RespParser struct { Options ParserOptions // contains filtered or unexported fields }
RespParser implements a stack machine to support RESP's potentially infinite nested arrays.
When there is insufficient data to make progress, the stack is left in its current state and execution is resumed by calling run on the top stack frame when new data is available from the network. Similarly, whenever the state of reading data from the Reader changes, the state of the stack must change by pushing or popping frames.
When a stack frame finishes execution it records its result in the prior stack frame. The first frame of the stack is the "root" of the parse tree, and is a dummy frame to store the final parse result, and has no associated logic. The parse is complete when stack contains only this root frame.
func NewParser ¶
func NewParser(r *reader.Reader) *RespParser
NewParser creates a parser ready to read a single RESP value from r.
func (*RespParser) BulkArray ¶
func (p *RespParser) BulkArray() [][]byte
func (*RespParser) Reset ¶
func (p *RespParser) Reset(r *reader.Reader)
Reset discards all current state and prepares the parser to read a single RESP value from r.
func (*RespParser) Result ¶
func (p *RespParser) Result() interface{}
func (*RespParser) Run ¶
func (p *RespParser) Run() error