parser

package
v0.0.0-...-262ee3b Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRLF            = "\r\n"
	EmptyBulkString = "$-1" + CRLF
	PING            = "PING"
)
View Source
const (
	StringBegin     = '+'
	ErrorBegin      = '-'
	IntegerBegin    = ':'
	BulkStringBegin = '$'
	ArrayBegin      = '*'
)

Variables

This section is empty.

Functions

func ParseStream

func ParseStream(reader io.Reader) <-chan *Payload

从reader中解析数据流成resp命令

func SendProtocolError

func SendProtocolError(ch chan<- *Payload, msg string)

Types

type Array

type Array struct {
	Args [][]byte
}

func NewArray

func NewArray(strs [][]byte) *Array

func (*Array) Serialize

func (array *Array) Serialize() []byte

type BulkString

type BulkString struct {
	Arg []byte
}

func MakeNullBulkReply

func MakeNullBulkReply() *BulkString

func NewBulkString

func NewBulkString(data []byte) *BulkString

func (*BulkString) Serialize

func (bs *BulkString) Serialize() []byte

type Error

type Error struct {
	Arg string
}

func NewError

func NewError(data string) *Error

func (*Error) Serialize

func (e *Error) Serialize() []byte

type Integer

type Integer struct {
	Arg int64
}

func NewInteger

func NewInteger(num int64) *Integer

func (*Integer) Serialize

func (e *Integer) Serialize() []byte

type Payload

type Payload struct {
	Data RespData
	Err  error
}

type RespData

type RespData interface {
	Serialize() []byte
}

type String

type String struct {
	Arg string
}

func MakeOKReply

func MakeOKReply() *String

func NewString

func NewString(data string) *String

func (*String) Serialize

func (ss *String) Serialize() []byte

Jump to

Keyboard shortcuts

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