resp

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

RESP protocol models for requests and responses

Command processor handling the business logic for RESP. Accepts and returns a byte slice on the processing channel. It is not meant to be instanciated, hence no struct here.

Index

Constants

View Source
const (
	DT_SIMPLE_STRING    = '+'
	DT_SIMPLE_ERROR     = '-'
	DT_INTEGER          = ':'
	DT_BULK_STRINGS     = '$'
	DT_ARRAYS           = '*'
	DT_NULLS            = '_'
	DT_BOOLEANS         = '#'
	DT_DOUBLES          = ','
	DT_BIG_NUMBERS      = '('
	DT_BULK_ERRORS      = '|'
	DT_VERBATIM_STRINGS = '='
	DT_MAPS             = '%'
	DT_SETS             = '~'
	DT_PUSHES           = '>'
)
View Source
const (
	RESP_OK  = "OK"
	RESP_ERR = "ERR"
)

Variables

This section is empty.

Functions

func StartCommandProcessor added in v0.3.0

func StartCommandProcessor(requestChannel <-chan NetworkRequest, storage KVStorage)

Redis proccesses in a single thread. This "event loop" provides the same behaviour while offering concurrency for the incoming connections. It also means the storage does not have to worry about race conditions.

Types

type KVStorage added in v0.3.0

type KVStorage interface {
	Get(key string) storage.Entry
	Set(key string, value storage.Entry)
	Delete(key string)
}

Open up for different kinds of storage in the future

type NetworkRequest added in v0.5.0

type NetworkRequest struct {
	ResponseChannel chan<- []byte
	Data            []byte
}

Requests from the network layer now have their own ResponseChannels The internal types are still generic.

type RespCommand

type RespCommand string
const (
	RESP_GET  RespCommand = "GET"
	RESP_SET  RespCommand = "SET"
	RESP_INCR RespCommand = "INCR"
	RESP_DEL  RespCommand = "DEL"
)

type RespExecRequest added in v0.5.0

type RespExecRequest struct {
	ResponseChannel chan<- []byte
	// contains filtered or unexported fields
}

Actual execution of the validated commands are no offloaded to new goroutines.

type RespFunc added in v0.4.0

type RespFunc = func(request *RespRequest, kv KVStorage) (*RespResponse, error)

type RespRequest

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

type RespResponse

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

type ResponseDataType

type ResponseDataType byte

Jump to

Keyboard shortcuts

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