goresp

package module
v0.0.0-...-82c6f67 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: Apache-2.0 Imports: 3 Imported by: 1

README

Build Status Coverage Status codebeat badge Go Report Card CII Best Practices FOSSA Status

goresp

Go implementation for RESP (REdis Serialization Protocol)

Documentation

For documentation see Godoc.

Data types

This table has examples for how data will be encoded and decoded.

RESP Representation Human-readable RESP Type Go Representation
"\r\n" (empty) undefined nil
":1\r\n" 1 Integer int64(1)
"+abc\r\n" "abc" Simple String "abc"
"+\r\n" "" Simple String ""
"-abc\r\n" "abc" Error error (msg=abc)
"-\r\n" "" Error error
"$5\r\nabc\r\n\r\n" "abc\r\n" Bulk String []byte{'a','b','c'}
"$0\r\n\r\n" "" Bulk String []byte{}
"*0\r\n" [] Array []interface{}{}
"*2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n" ["foo", "bar"] Array []interface{}{[]byte{'f','o','o'}, []byte{'b','a','r'}}
"*2\r\n:1\r\n$3\r\nfoo\r\n" [6, "foobar"] Array (mixed) []interface{}{int64(1), []byte{'f', 'o', 'o'}}

Benchmarks

Benchmark name (1) (2) (3) (4)
BenchmarkReadSmallString 20000000 88.7 16 2
BenchmarkReadInteger 10000000 126 16 3
BenchmarkReadBulkString 20000000 107 16 3
BenchmarkReadArray 3000000 580 176 14
  • (1): Total Repetitions achieved in constant time, higher means more confident result
  • (2): Single Repetition Duration (ns/op), lower is better
  • (3): Heap Memory (B/op), lower is better
  • (4): Average Allocations per Repetition (allocs/op), lower is better

TODO List

[X] Change Simple string decoded type to string

License

Unless otherwise noted, All source files in this library are distributed under the Apache License 2.0 found in the LICENSE file.

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnexpectedEOF thrown when unmarshaling an incomplete message
	ErrUnexpectedEOF = errors.New("Unexpected EOF")
	// ErrInvalidMessage thrown when the message is not in any form of standard RESP format
	ErrInvalidMessage = errors.New("Invalid message")
)
View Source
var (
	ErrUnsupportedType = errors.New("Unsupported Type")
)

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

func Unmarshal

func Unmarshal(reader io.Reader) (interface{}, error)

Unmarshal decodes RESP messages to its corresponding golang type

Types

This section is empty.

Jump to

Keyboard shortcuts

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