Documentation
¶
Index ¶
- Constants
- func AppendAny(b []byte, v interface{}) []byte
- func AppendArray(b []byte, n int) []byte
- func AppendBulk(b []byte, bulk []byte) []byte
- func AppendBulkFloat(dst []byte, f float64) []byte
- func AppendBulkInt(dst []byte, x int64) []byte
- func AppendBulkString(b []byte, bulk string) []byte
- func AppendBulkUint(dst []byte, x uint64) []byte
- func AppendError(b []byte, s string) []byte
- func AppendInt(b []byte, n int64) []byte
- func AppendNull(b []byte) []byte
- func AppendOK(b []byte) []byte
- func AppendString(b []byte, s string) []byte
- func AppendTile38(b []byte, data []byte) []byte
- func AppendUint(b []byte, n uint64) []byte
- type Command
- type Kind
- type Marshaler
- type RESP
- type SimpleInt
- type SimpleString
- type Type
- type Writer
Constants ¶
const ( Integer = ':' String = '+' Bulk = '$' Array = '*' Error = '-' )
Various RESP kinds
Variables ¶
This section is empty.
Functions ¶
func AppendAny ¶
AppendAny appends any type to valid Redis type.
nil -> null error -> error (adds "ERR " when first word is not uppercase) string -> bulk-string numbers -> bulk-string []byte -> bulk-string bool -> bulk-string ("0" or "1") slice -> array map -> array with key/value pairs SimpleString -> string SimpleInt -> integer Marshaler -> raw bytes everything-else -> bulk-string representation using fmt.Sprint()
func AppendArray ¶
AppendArray appends a Redis protocol array to the input bytes.
func AppendBulk ¶
AppendBulk appends a Redis protocol bulk byte slice to the input bytes.
func AppendBulkFloat ¶
AppendBulkFloat appends a float64, as bulk bytes.
func AppendBulkInt ¶
AppendBulkInt appends an int64, as bulk bytes.
func AppendBulkString ¶
AppendBulkString appends a Redis protocol bulk string to the input bytes.
func AppendBulkUint ¶
AppendBulkUint appends an uint64, as bulk bytes.
func AppendError ¶
AppendError appends a Redis protocol error to the input bytes.
func AppendNull ¶
AppendNull appends a Redis protocol null to the input bytes.
func AppendString ¶
AppendString appends a Redis protocol string to the input bytes.
func AppendTile38 ¶
AppendTile38 appends a Tile38 message to the input bytes.
func AppendUint ¶
AppendUint appends a Redis protocol uint64 to the input bytes.
Types ¶
type Command ¶
type Command struct { Raw []byte // Raw is an encoded RESP message Args [][]byte // Args is a series of arguments that make up the command }
Command represents a RESP command
type Kind ¶
type Kind int
Kind is the kind of command
func ReadNextCommand ¶
func ReadNextCommand(packet []byte, argsbuf [][]byte) ( complete bool, args [][]byte, kind Kind, leftover []byte, err error, )
ReadNextCommand reads the next command from the provided packet. It's possible that the packet contains multiple commands, or zero commands when the packet is incomplete. 'argsbuf' is an optional reusable buffer and it can be nil. 'complete' indicates that a command was read. false means no more commands. 'args' are the output arguments for the command. 'kind' is the type of command that was read. 'leftover' is any remaining unused bytes which belong to the next command. 'err' is returned when a protocol error was encountered.
type Marshaler ¶
type Marshaler interface {
MarshalRESP() []byte
}
Marshaler is the interface implemented by types that can marshal themselves into a Redis response type from an *Any call. The return value is not check for validity.
type RESP ¶
RESP ...
func ReadNextRESP ¶
ReadNextRESP returns the next resp in b and returns the number of bytes the took up the result.
type SimpleInt ¶
type SimpleInt int
SimpleInt is for representing a non-bulk representation of a int from an *Any call.
type SimpleString ¶
type SimpleString string
SimpleString is for representing a non-bulk representation of a string from an *Any call.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer allows for writing RESP messages
func (*Writer) WriteArray ¶
WriteArray writes an array header