Documentation ¶
Index ¶
- func ErrNotFound(key string) error
- func ErrUnknownCommand(cmd string) error
- func ErrWrongNumberOfArgs(cmd string) error
- func NotFound(key string) string
- func UnknownCommand(cmd string) string
- func WrongData(cmd string) string
- func WrongNumberOfArgs(cmd string) string
- type Client
- type ClientInfo
- type CommandDescription
- type CommandDescriptions
- type Config
- type DB
- type Handler
- type HandlerFunc
- type Server
- func (srv *Server) Handle(name string, h Handler)
- func (srv *Server) HandleFunc(name string, fn HandlerFunc)
- func (srv *Server) HandleStream(name string, h StreamHandler)
- func (srv *Server) HandleStreamFunc(name string, fn StreamHandlerFunc)
- func (srv *Server) Info() *ServerInfo
- func (srv *Server) Serve(lis net.Listener) error
- type ServerInfo
- func (i *ServerInfo) ClientInfo() []ClientInfo
- func (i *ServerInfo) Fetch(name string) *info.Section
- func (i *ServerInfo) Find(name string) *info.Section
- func (i *ServerInfo) NumClients() int
- func (i *ServerInfo) Register(c *Client)
- func (i *ServerInfo) String() string
- func (i *ServerInfo) TotalCommands() int64
- func (i *ServerInfo) TotalConnections() int64
- type StreamHandler
- type StreamHandlerFunc
- type SubCommands
- type WrapperFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrNotFound ¶ added in v1.0.0
func ErrUnknownCommand ¶ added in v1.0.0
ErrUnknownCommand returns an unknown command error
func ErrWrongNumberOfArgs ¶ added in v1.0.0
ErrWrongNumberOfArgs returns an unknown command error
func UnknownCommand ¶ added in v1.0.0
UnknownCommand returns an unknown command error string
func WrongNumberOfArgs ¶ added in v1.0.0
WrongNumberOfArgs returns an unknown command error string
Types ¶
type Client ¶ added in v1.0.0
type Client struct {
// contains filtered or unexported fields
}
Client contains information about a client connection
func GetClient ¶ added in v1.0.0
GetClient retrieves the client from a the context. This function may return nil if a client is not set.
func (*Client) Close ¶ added in v1.0.0
func (c *Client) Close()
Close will disconnect as soon as all pending replies have been written to the client
func (*Client) RemoteAddr ¶ added in v1.0.0
RemoteAddr return the remote client address
func (*Client) SetContext ¶ added in v1.0.0
SetContext sets the client's context
type ClientInfo ¶ added in v1.0.0
type ClientInfo struct { // ID is the internal client ID ID uint64 // RemoteAddr is the remote address string RemoteAddr string // LastCmd is the last command called by this client LastCmd string // CreateTime returns the time at which the client has // connected to the server CreateTime time.Time // AccessTime returns the time of the last access AccessTime time.Time }
ClientInfo contains client stats
func (*ClientInfo) String ¶ added in v1.0.0
func (i *ClientInfo) String() string
String generates an info string
type CommandDescription ¶ added in v1.0.0
type CommandDescription struct { // Name is the command name, returned as a lowercase string. Name string // Arity is the command arity specification. // https://redis.io/commands/command#command-arity. // It follows a simple pattern: // positive if command has fixed number of required arguments. // negative if command has minimum number of required arguments, but may have more. Arity int64 // Flags is an enumeration of command flags. // https://redis.io/commands/command#flags. Flags []string // FirstKey is the position of first key in argument list. // https://redis.io/commands/command#first-key-in-argument-list FirstKey int64 // LastKey is the position of last key in argument list. // https://redis.io/commands/command#last-key-in-argument-list LastKey int64 // KeyStepCount is the step count for locating repeating keys. // https://redis.io/commands/command#step-count KeyStepCount int64 }
CommandDescription describes supported commands
type CommandDescriptions ¶ added in v1.0.0
type CommandDescriptions []CommandDescription
CommandDescriptions returns a command handler. https://redis.io/commands/command
func (CommandDescriptions) ServeRedeo ¶ added in v1.0.0
func (s CommandDescriptions) ServeRedeo(w resp.ResponseWriter, c *resp.Command)
type Handler ¶ added in v1.0.0
type Handler interface { // ServeRedeo serves a request. ServeRedeo(w resp.ResponseWriter, c *resp.Command) }
Handler is an abstract handler interface for responding to commands
func Echo ¶ added in v1.0.0
func Echo() Handler
Echo returns an echo handler. https://redis.io/commands/echo
func Info ¶ added in v1.0.0
Info returns an info handler. https://redis.io/commands/info
func Ping ¶ added in v1.0.0
func Ping() Handler
Ping returns a ping handler. https://redis.io/commands/ping
type HandlerFunc ¶ added in v1.0.0
type HandlerFunc func(w resp.ResponseWriter, c *resp.Command)
HandlerFunc is a callback function, implementing Handler.
func (HandlerFunc) ServeRedeo ¶ added in v1.0.0
func (f HandlerFunc) ServeRedeo(w resp.ResponseWriter, c *resp.Command)
ServeRedeo calls f(w, c).
type Server ¶ added in v1.0.0
type Server struct {
// contains filtered or unexported fields
}
func (*Server) HandleFunc ¶ added in v1.0.0
func (srv *Server) HandleFunc(name string, fn HandlerFunc)
HandleFunc registers a handler func for a command.
func (*Server) HandleStream ¶ added in v1.0.0
func (srv *Server) HandleStream(name string, h StreamHandler)
HandleStream registers a handler for a streaming command.
func (*Server) HandleStreamFunc ¶ added in v1.0.0
func (srv *Server) HandleStreamFunc(name string, fn StreamHandlerFunc)
HandleStreamFunc registers a handler func for a command
func (*Server) Info ¶ added in v1.0.0
func (srv *Server) Info() *ServerInfo
Info returns the server info registry
type ServerInfo ¶ added in v1.0.0
type ServerInfo struct {
// contains filtered or unexported fields
}
ServerInfo contains server stats
func (*ServerInfo) ClientInfo ¶ added in v1.0.0
func (i *ServerInfo) ClientInfo() []ClientInfo
ClientInfo returns details about connected clients
func (*ServerInfo) Fetch ¶ added in v1.0.0
func (i *ServerInfo) Fetch(name string) *info.Section
Fetch finds or creates an info section. This method is not thread-safe.
func (*ServerInfo) Find ¶ added in v1.0.0
func (i *ServerInfo) Find(name string) *info.Section
Find finds an info section by name.
func (*ServerInfo) NumClients ¶ added in v1.0.0
func (i *ServerInfo) NumClients() int
NumClients returns the number of connected clients
func (*ServerInfo) Register ¶ added in v1.0.0
func (i *ServerInfo) Register(c *Client)
func (*ServerInfo) String ¶ added in v1.0.0
func (i *ServerInfo) String() string
String generates an info string
func (*ServerInfo) TotalCommands ¶ added in v1.0.0
func (i *ServerInfo) TotalCommands() int64
TotalCommands returns the total number of commands executed since the start of the server.
func (*ServerInfo) TotalConnections ¶ added in v1.0.0
func (i *ServerInfo) TotalConnections() int64
TotalConnections returns the total number of connections made since the start of the server.
type StreamHandler ¶ added in v1.0.0
type StreamHandler interface { // ServeRedeoStream serves a streaming request. ServeRedeoStream(w resp.ResponseWriter, c *resp.CommandStream) }
StreamHandler is an interface for responding to streaming commands
type StreamHandlerFunc ¶ added in v1.0.0
type StreamHandlerFunc func(w resp.ResponseWriter, c *resp.CommandStream)
StreamHandlerFunc is a callback function, implementing Handler.
func (StreamHandlerFunc) ServeRedeoStream ¶ added in v1.0.0
func (f StreamHandlerFunc) ServeRedeoStream(w resp.ResponseWriter, c *resp.CommandStream)
ServeRedeoStream calls f(w, c).
type SubCommands ¶ added in v1.0.0
SubCommands returns a handler that is parsing sub-commands
func (SubCommands) ServeRedeo ¶ added in v1.0.0
func (s SubCommands) ServeRedeo(w resp.ResponseWriter, c *resp.Command)
type WrapperFunc ¶ added in v1.0.0
WrapperFunc implements Handler, accepts a command and must return one of the following types:
nil error string []byte bool float32, float64 int, int8, int16, int32, int64 uint, uint8, uint16, uint32, uint64 resp.CustomResponse instances slices of any of the above typs maps containing keys and values of any of the above types
func (WrapperFunc) ServeRedeo ¶ added in v1.0.0
func (f WrapperFunc) ServeRedeo(w resp.ResponseWriter, c *resp.Command)
ServeRedeo implements Handler
Directories ¶
Path | Synopsis |
---|---|
Package client implements a minimalist client for working with redis servers.
|
Package client implements a minimalist client for working with redis servers. |
main
|
|
Package pool is a generic, high-performance pool for net.Conn objects.
|
Package pool is a generic, high-performance pool for net.Conn objects. |
Package resp implements low-level primitives for dealing with RESP (REdis Serialization Protocol).
|
Package resp implements low-level primitives for dealing with RESP (REdis Serialization Protocol). |