protocol

package
v0.0.0-...-edb8eda Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandPing = "PING"
	CommandSet  = "SET"
	CommandGet  = "GET"
	CommandEcho = "ECHO"
)
View Source
const (
	RESPSimpleString = '+'
	RESPBulkString   = '$'
	RESPArray        = '*'
	RESPError        = '-'
)

Variables

View Source
var (
	ErrWrongNumberOfArguments = errors.New("ERR wrong number of arguments for command")
	ErrSyntax                 = errors.New("ERR syntax error")
)
View Source
var (
	CLRFBytes = []byte{'\r', '\n'}
)

Functions

func BulkString

func BulkString(val string) []byte

func Error

func Error(val error) []byte

func Nil

func Nil() []byte

func SimpleString

func SimpleString(val string) []byte

Types

type Command

type Command struct {
	Type string
	Args []string
}

func ParseRequest

func ParseRequest(buf *bytes.Buffer) (*Command, error)

type Executor

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

func NewExecutor

func NewExecutor(db Storage) *Executor

func (*Executor) Echo

func (e *Executor) Echo(args []string) []byte

func (*Executor) Execute

func (e *Executor) Execute(cmd *Command) []byte

func (*Executor) Get

func (e *Executor) Get(args []string) []byte

func (*Executor) Ping

func (e *Executor) Ping(args []string) []byte

func (*Executor) Set

func (e *Executor) Set(args []string) []byte

type Storage

type Storage interface {
	Set(string, any) error
	Get(string) (any, error)
}

Jump to

Keyboard shortcuts

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