Documentation ¶
Index ¶
- Variables
- type Cmd
- type DisconnectHandler
- type Peer
- func (c *Peer) Block(f func(*Writer))
- func (c *Peer) Close()
- func (c *Peer) Flush()
- func (c *Peer) OnDisconnect(f func())
- func (c *Peer) WriteBulk(s string)
- func (c *Peer) WriteError(e string)
- func (c *Peer) WriteInline(s string)
- func (c *Peer) WriteInt(i int)
- func (c *Peer) WriteLen(n int)
- func (c *Peer) WriteNull()
- func (c *Peer) WriteOK()
- type Server
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrProtocol = errors.New("invalid request")
ErrProtocol is the general error for unexpected input
Functions ¶
This section is empty.
Types ¶
type DisconnectHandler ¶
type DisconnectHandler func(c *Peer)
type Peer ¶
type Peer struct { Ctx interface{} // anything goes, server won't touch this // contains filtered or unexported fields }
Peer is a client connected to the server
func (*Peer) Close ¶
func (c *Peer) Close()
Close the client connection after the current command is done.
func (*Peer) Flush ¶
func (c *Peer) Flush()
Flush the write buffer. Called automatically after every redis command
func (*Peer) OnDisconnect ¶
func (c *Peer) OnDisconnect(f func())
Register a function to execute on disconnect. There can be multiple functions registered.
func (*Peer) WriteInline ¶
WriteInline writes a redis inline string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a simple redis server
func (*Server) ClientsLen ¶
ClientsLen gives the number of connected clients right now
func (*Server) Close ¶
func (s *Server) Close()
Close a server started with NewServer. It will wait until all clients are closed.
func (*Server) Register ¶
Register a command. It can't have been registered before. Safe to call on a running server.
func (*Server) TotalCommands ¶
TotalCommands is total (known) commands since this the server started
func (*Server) TotalConnections ¶
TotalConnections give the number of clients connected since the server started, including the currently connected ones
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer is given to the callback in Block()
func (*Writer) WriteInline ¶
WriteInline writes a redis inline string