proto

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEOM = errors.New("EOM")

ErrEOM is the error returned by Array::Next() when no more message is available.

View Source
var ErrNil = errors.New("NIL")

ErrNil is the error returned by Message::String() when the bytes are nil.

Functions

This section is empty.

Types

type Array

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

Array represents a array message.

func NewArray

func NewArray() *Array

NewArray returns a new array message.

func (*Array) Append

func (array *Array) Append(msg *Message)

Append adds a message into the array.

func (*Array) Next

func (array *Array) Next() (*Message, error)

Next returns a next message.

func (*Array) NextArray

func (array *Array) NextArray() (*Array, error)

NextArray returns the message array if the message type is array, otherwise it returns an error.

func (*Array) NextBytes

func (array *Array) NextBytes() ([]byte, error)

NextBytes returns the next byte message.

func (*Array) NextError

func (array *Array) NextError() (error, error)

NextError returns the message error if the message type is error, otherwise it returns an error.

func (*Array) NextInteger

func (array *Array) NextInteger() (int, error)

NextInteger returns the message integer if the message type is integer, otherwise it returns an error.

func (*Array) NextMessage

func (array *Array) NextMessage() (*Message, error)

NextMessage returns the next message if any, otherwise it returns error.

func (*Array) NextMessages

func (array *Array) NextMessages() ([]*Message, error)

NextMessages returns all unread messages.

func (*Array) NextString

func (array *Array) NextString() (string, error)

NextString returns the message string if the message type is string, otherwise it returns an error.

func (*Array) RESPBytes

func (array *Array) RESPBytes() ([]byte, error)

RESPBytes returns the RESP byte representation.

func (*Array) Reverse added in v1.1.0

func (array *Array) Reverse() *Array

Reverse returns the reversed array.

func (*Array) ReverseBy added in v1.1.0

func (array *Array) ReverseBy(step int) *Array

ReverseBy returns the reversed array with the specified step.

func (*Array) Size

func (array *Array) Size() int

Size returns the array size.

type Message

type Message struct {
	Type MessageType
	// contains filtered or unexported fields
}

Message represents a message of Redis serialization protocol.

func NewMessageWithType

func NewMessageWithType(t MessageType) *Message

NewMessageWithType returns a new message instance with the specified type.

func (*Message) Append added in v1.0.0

func (msg *Message) Append(arrayMsg *Message) error

Append appends a message to the array message.

func (*Message) Array

func (msg *Message) Array() (*Array, error)

Array returns the message array if the message type is array, otherwise it returns an error.

func (*Message) Bytes

func (msg *Message) Bytes() ([]byte, error)

Bytes returns the message raw bytes.

func (*Message) Error

func (msg *Message) Error() (error, error)

Error returns the message error if the message type is error, otherwise it returns an error.

func (*Message) Integer

func (msg *Message) Integer() (int, error)

Integer returns the message integer if the message type is integer, otherwise it returns an error.

func (*Message) IsArray

func (msg *Message) IsArray() bool

IsArray returns true if the message type is array, otherwise false.

func (*Message) IsBulk

func (msg *Message) IsBulk() bool

IsBulk returns true if the message type is bulk, otherwise false.

func (*Message) IsError

func (msg *Message) IsError() bool

IsError returns true if the message type is error, otherwise false.

func (*Message) IsInteger

func (msg *Message) IsInteger() bool

IsInteger returns true if the message type is integer, otherwise false.

func (*Message) IsNil added in v1.0.0

func (msg *Message) IsNil() bool

IsNil returns true if the message type is bulk and the message bytes are nil, otherwise false.

func (*Message) IsString

func (msg *Message) IsString() bool

IsString returns true if the message type is string, otherwise false.

func (*Message) IsType

func (msg *Message) IsType(t MessageType) bool

IsType returns true if the message type is the specified type, otherwise false.

func (*Message) RESPBytes

func (msg *Message) RESPBytes() ([]byte, error)

RESPBytes returns the RESP byte representation.

func (*Message) SetArray

func (msg *Message) SetArray(array *Array) *Message

SetArray sets an array to the message.

func (*Message) SetBytes

func (msg *Message) SetBytes(bytes []byte) *Message

SetBytes sets a byte array to the message.

func (*Message) String

func (msg *Message) String() (string, error)

String returns the message string if the message type is string, otherwise it returns an error.

type MessageType

type MessageType int

MessageType represents a message type of Redis serialization protocol.

const (
	StringMessage MessageType = iota
	ErrorMessage
	IntegerMessage
	BulkMessage
	ArrayMessage
)

type Parser

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

Paser represents a Redis serialization protocol (RESP) parser.

func NewParserWithBytes

func NewParserWithBytes(msgBytes []byte) *Parser

NewParserWithBytes returns a new parser for the specified bytes.

func NewParserWithReader

func NewParserWithReader(msgReader io.Reader) *Parser

NewParserWithReader returns a new parser for the specified reader.

func (*Parser) Next

func (parser *Parser) Next() (*Message, error)

Next returns a next message.

Jump to

Keyboard shortcuts

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