redis

package
v0.0.0-...-a5c5f28 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2013 Docker, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.

The following only applies to changes made to this file as part of ELEME development.

Portions Copyright (c) 2019 ELEME, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMethodNotSupported   = NewError("Method is not supported")
	ErrNotEnoughArgs        = NewError("Not enough arguments for the command")
	ErrTooMuchArgs          = NewError("Too many arguments for the command")
	ErrWrongArgsNumber      = NewError("Wrong number of arguments")
	ErrExpectInteger        = NewError("Expected integer")
	ErrExpectPositivInteger = NewError("Expected positive integer")
	ErrExpectMorePair       = NewError("Expected at least one key val pair")
	ErrExpectEvenPair       = NewError("Got uneven number of key val pairs")
	ErrArgsTooLong          = NewError("Args is too long")
)
View Source
var (
	ErrParseTimeout = errors.New("timeout is not an integer or out of range")
)

Functions

func Debugf

func Debugf(format string, a ...interface{})

Debug function, if the debug flag is set, then display. Do nothing otherwise If Docker is in damon mode, also send the debug info on the socket Convenience debug function, courtesy of http://github.com/dotcloud/docker

func ReplyToString

func ReplyToString(r ReplyWriter) (string, error)

Types

type BulkReply

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

func (*BulkReply) WriteTo

func (r *BulkReply) WriteTo(w io.Writer) (int64, error)

type ChannelWriter

type ChannelWriter struct {
	FirstReply []interface{}
	Channel    chan []interface{}
	// contains filtered or unexported fields
}

func (*ChannelWriter) WriteTo

func (c *ChannelWriter) WriteTo(w io.Writer) (int64, error)

type CheckerFn

type CheckerFn func(request *Request) (reflect.Value, ReplyWriter)

type Config

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

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Handler

func (c *Config) Handler(h interface{}) *Config

func (*Config) Host

func (c *Config) Host(h string) *Config

func (*Config) Port

func (c *Config) Port(p int) *Config

func (*Config) Proto

func (c *Config) Proto(p string) *Config

type Conn

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

func (*Conn) Close

func (c *Conn) Close()

type Database

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

func NewDatabase

func NewDatabase(parent *Database) *Database

type DefaultHandler

type DefaultHandler struct {
	*Database
	// contains filtered or unexported fields
}

func NewDefaultHandler

func NewDefaultHandler() *DefaultHandler

func (*DefaultHandler) Blpop

func (h *DefaultHandler) Blpop(key string, keys ...string) (data [][]byte, err error)

func (*DefaultHandler) Brpop

func (h *DefaultHandler) Brpop(key string, keys ...string) (data [][]byte, err error)

func (*DefaultHandler) Del

func (h *DefaultHandler) Del(key string, keys ...string) (int, error)

func (*DefaultHandler) Get

func (h *DefaultHandler) Get(key string) ([]byte, error)

func (*DefaultHandler) Hget

func (h *DefaultHandler) Hget(key, subkey string) ([]byte, error)

func (*DefaultHandler) Hgetall

func (h *DefaultHandler) Hgetall(key string) (HashValue, error)

func (*DefaultHandler) Hset

func (h *DefaultHandler) Hset(key, subkey string, value []byte) (int, error)

func (*DefaultHandler) Lindex

func (h *DefaultHandler) Lindex(key string, index int) ([]byte, error)

func (*DefaultHandler) Lpush

func (h *DefaultHandler) Lpush(key string, value []byte, values ...[]byte) (int, error)

func (*DefaultHandler) Lrange

func (h *DefaultHandler) Lrange(key string, start, stop int) ([][]byte, error)

func (*DefaultHandler) Monitor

func (h *DefaultHandler) Monitor() (*MonitorReply, error)

func (*DefaultHandler) Ping

func (h *DefaultHandler) Ping() (*StatusReply, error)

func (*DefaultHandler) Publish

func (h *DefaultHandler) Publish(key string, value []byte) (int, error)

func (*DefaultHandler) Rpush

func (h *DefaultHandler) Rpush(key string, value []byte, values ...[]byte) (int, error)

func (*DefaultHandler) Select

func (h *DefaultHandler) Select(key string) error

func (*DefaultHandler) Set

func (h *DefaultHandler) Set(key string, value []byte) error

func (*DefaultHandler) Subscribe

func (h *DefaultHandler) Subscribe(channels ...[]byte) (*MultiChannelWriter, error)

type ErrorReply

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

func NewError

func NewError(message string) *ErrorReply

func (*ErrorReply) Error

func (er *ErrorReply) Error() string

func (*ErrorReply) WriteTo

func (er *ErrorReply) WriteTo(w io.Writer) (int64, error)

type HandlerFn

type HandlerFn func(r *Request) (ReplyWriter, error)

type HashBrStack

type HashBrStack map[string]*Stack

type HashHash

type HashHash map[string]HashValue

type HashSub

type HashSub map[string][]*ChannelWriter

type HashValue

type HashValue map[string][]byte

type Integer64Reply

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

func (*Integer64Reply) WriteTo

func (r *Integer64Reply) WriteTo(w io.Writer) (int64, error)

type IntegerReply

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

func (*IntegerReply) WriteTo

func (r *IntegerReply) WriteTo(w io.Writer) (int64, error)

type MonitorReply

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

func (*MonitorReply) WriteTo

func (r *MonitorReply) WriteTo(w io.Writer) (int64, error)

type MultiBulkReply

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

for nil reply in multi bulk just set []byte as nil

func MultiBulkFromMap

func MultiBulkFromMap(m map[string]interface{}) *MultiBulkReply

func (*MultiBulkReply) WriteTo

func (r *MultiBulkReply) WriteTo(w io.Writer) (int64, error)

type MultiChannelWriter

type MultiChannelWriter struct {
	Chans []*ChannelWriter
}

func (*MultiChannelWriter) WriteTo

func (c *MultiChannelWriter) WriteTo(w io.Writer) (n int64, err error)

type ReplyWriter

type ReplyWriter io.WriterTo

type Request

type Request struct {
	Name       string
	Args       [][]byte
	Host       string
	ClientChan chan struct{}
}

func (*Request) ExpectArgument

func (r *Request) ExpectArgument(index int) ReplyWriter

func (*Request) GetInteger

func (r *Request) GetInteger(index int) (int, ReplyWriter)

func (*Request) GetMap

func (r *Request) GetMap(index int) (map[string][]byte, ReplyWriter)

func (*Request) GetPositiveInteger

func (r *Request) GetPositiveInteger(index int) (int, ReplyWriter)

func (*Request) GetString

func (r *Request) GetString(index int) (string, ReplyWriter)

func (*Request) GetStringSlice

func (r *Request) GetStringSlice(index int) ([]string, ReplyWriter)

func (*Request) HasArgument

func (r *Request) HasArgument(index int) bool

type Server

type Server struct {
	Proto        string
	Addr         string // TCP address to listen on, ":6389" if empty
	MonitorChans []chan string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(c *Config, timeout int) (*Server, error)

func (*Server) Apply

func (srv *Server) Apply(r *Request, session *session.Session) (reply ReplyWriter, err error)

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

func (*Server) Register

func (srv *Server) Register(name string, fn HandlerFn)

func (*Server) RegisterFct

func (srv *Server) RegisterFct(key string, f interface{}) error

func (*Server) Serve

func (srv *Server) Serve(l net.Listener) error

Serve accepts incoming connections on the Listener l, creating a new service goroutine for each. The service goroutines read requests and then call srv.Handler to reply to them.

func (*Server) ServeClient

func (srv *Server) ServeClient(conn net.Conn) (err error)

Serve starts a new redis session, using `conn` as a transport. It reads commands using the redis protocol, passes them to `handler`, and returns the result.

type Stack

type Stack struct {
	sync.Mutex
	Key string

	Chan chan *Stack
	// contains filtered or unexported fields
}

func NewStack

func NewStack(key string) *Stack

func (*Stack) GetIndex

func (s *Stack) GetIndex(index int) []byte

GetIndex return the element at the requested index. If no element correspond, return nil.

func (*Stack) Len

func (s *Stack) Len() int

func (*Stack) PopBack

func (s *Stack) PopBack() []byte

func (*Stack) PopFront

func (s *Stack) PopFront() []byte

func (*Stack) PushBack

func (s *Stack) PushBack(val []byte)

func (*Stack) PushFront

func (s *Stack) PushFront(val []byte)

type StatusReply

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

func (*StatusReply) WriteTo

func (r *StatusReply) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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