resp

package
v4.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package resp is an umbrella package which covers both the old RESP protocol (resp2) and the new one (resp3), allowing clients to choose which one they care to use

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrConnUnusable

func ErrConnUnusable(err error) error

ErrConnUnusable takes an existing error and, if it is wrapped in an ErrConnUsable, unwraps the ErrConnUsable from around it.

Types

type ErrConnUsable

type ErrConnUsable struct {
	Err error
}

ErrConnUsable is used to wrap an error encountered while marshaling or unmarshaling a message on a connection. It indicates that the network connection is still healthy and that there are no partially written/read messages on the stream.

func (ErrConnUsable) Error

func (ed ErrConnUsable) Error() string

func (ErrConnUsable) Unwrap

func (ed ErrConnUsable) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type LenReader

type LenReader interface {
	io.Reader
	Len() int
}

LenReader adds an additional method to io.Reader, returning how many bytes are left till be read until an io.EOF is reached.

func NewLenReader

func NewLenReader(r io.Reader, l int) LenReader

NewLenReader wraps an existing io.Reader whose length is known so that it implements LenReader

type Marshaler

type Marshaler interface {
	MarshalRESP(io.Writer) error
}

Marshaler is the interface implemented by types that can marshal themselves into valid RESP.

NOTE It's important to keep track of whether a partial RESP message has been written to the Writer, and to use ErrConnUnusable when returning errors if a partial RESP message has not been written.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalRESP(*bufio.Reader) error
}

Unmarshaler is the interface implemented by types that can unmarshal a RESP description of themselves. UnmarshalRESP should _always_ fully consume a RESP message off the reader, unless there is an error returned from the reader itself. Use ErrConnUsable when applicable.

Directories

Path Synopsis
Package resp2 implements the original redis RESP protocol, a plaintext protocol which is also binary safe.
Package resp2 implements the original redis RESP protocol, a plaintext protocol which is also binary safe.
Package resp3 implements the upgraded redis RESP3 protocol, a plaintext protocol which is also binary safe and backwards compatible with the original RESP2 protocol.
Package resp3 implements the upgraded redis RESP3 protocol, a plaintext protocol which is also binary safe and backwards compatible with the original RESP2 protocol.

Jump to

Keyboard shortcuts

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