redisproto

package
v0.0.0-...-ecbb2dd Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

README

Introduction

This is a fork of radishproto to make it work with radish server.

radishproto is a go library to create server, service for RPC that compatible with redis protocol I use it for some projects that require RPC, redis-protocol is a good choice because it can be parsed fast and we have many client libraries that already exist to use. radishproto use it's own buffered reader to avoid memory copy.

Some other tool that use radishproto

  1. https://github.com/secmask/mqueue
  2. https://github.com/secmask/roller

License

radishproto is available under The MIT License (MIT).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExpectNumber   = &ProtocolError{"Expect Number"}
	ExpectNewLine  = &ProtocolError{"Expect Newline"}
	ExpectTypeChar = &ProtocolError{"Expect TypeChar"}

	ErrInvalidNumArg   = errors.New("TooManyArg")
	ErrInvalidBulkSize = errors.New("invalid bulk size")
	ErrLineTooLong     = errors.New("LineTooLong")

	ReadBufferInitSize = 1 << 16
	MaxNumArg          = 20
	MaxBulkSize        = 1 << 16
	MaxTelnetLine      = 1 << 10
)

Functions

func SendBulk

func SendBulk(w *bufio.Writer, val []byte) error

func SendBulkString

func SendBulkString(w *bufio.Writer, str string) error

func SendBulkStrings

func SendBulkStrings(w *bufio.Writer, strs []string) error

func SendBulks

func SendBulks(w *bufio.Writer, vals [][]byte) error

func SendError

func SendError(w *bufio.Writer, msg string) error

func SendInt

func SendInt(w *bufio.Writer, val int64) error

func SendObjects

func SendObjects(w *bufio.Writer, vals []interface{}) error

func SendString

func SendString(w *bufio.Writer, msg string) error

Types

type Command

type Command struct {
	Argv [][]byte
	Last bool
}

func (*Command) ArgCount

func (c *Command) ArgCount() int

func (*Command) Get

func (c *Command) Get(index int) []byte

func (*Command) IsLast

func (c *Command) IsLast() bool

IsLast is true if this command is the last one in receive buffer, command handler should call writer.Flush() after write response, helpful in process pipeline command.

type Parser

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

func NewParser

func NewParser(reader io.Reader) *Parser

func (*Parser) Commands

func (r *Parser) Commands() <-chan *Command

func (*Parser) ReadCommand

func (r *Parser) ReadCommand() (*Command, error)

type ProtocolError

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

func (*ProtocolError) Error

func (p *ProtocolError) Error() string

type Writer

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

func NewWriter

func NewWriter(sink io.Writer) *Writer

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

func (*Writer) WriteBulk

func (w *Writer) WriteBulk(val []byte) error

func (*Writer) WriteBulkString

func (w *Writer) WriteBulkString(s string) error

func (*Writer) WriteBulkStrings

func (w *Writer) WriteBulkStrings(bulks []string) error

func (*Writer) WriteBulks

func (w *Writer) WriteBulks(bulks ...[]byte) error

func (*Writer) WriteBulksSlice

func (w *Writer) WriteBulksSlice(args [][]byte) error

WriteBulksSlice ...

func (*Writer) WriteError

func (w *Writer) WriteError(s string) error

func (*Writer) WriteInt

func (w *Writer) WriteInt(val int64) error

func (*Writer) WriteObjects

func (w *Writer) WriteObjects(objs ...interface{}) error

func (*Writer) WriteObjectsSlice

func (w *Writer) WriteObjectsSlice(args []interface{}) error

WriteObjectsSlice works like WriteObjects, it useful when args is a slice that can be nil, in that case WriteObjects(nil) will understand as response 1 element array (nil element) see https://github.com/secmask/radishproto/issues/4 for details.

func (*Writer) WriteSimpleString

func (w *Writer) WriteSimpleString(s string) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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