Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Addresses() map[string]struct{}
- func (c *Client) Ban(addr string) error
- func (c *Client) Close(addr string) error
- func (c *Client) Get(addr string) *redis.Client
- func (c *Client) Pick() (*redis.Client, error)
- func (c *Client) Shutdown(ctx context.Context) error
- func (c *Client) Unban(addr string)
- type ConServer
- type Config
- type ConnWrapper
- type Handler
- type HandlerFunc
- type ListenerWrapper
- type ServeMux
- type ServeMuxWrapper
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( // CommandsTotal is total number of all requests broken down by command (get, put, etc.) and status. CommandsTotal = stats.NewInt64Counter() // ConnectionsTotal is total number of connections opened since the server started running. ConnectionsTotal = stats.NewInt64Counter() // CurrentConnections is current number of open connections. CurrentConnections = stats.NewInt64Gauge() // WrittenBytesTotal is total number of bytes sent by this server to network. WrittenBytesTotal = stats.NewInt64Counter() // ReadBytesTotal is total number of bytes read by this server from network. ReadBytesTotal = stats.NewInt64Counter() )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Ban ¶ added in v0.3.16
Ban closes the connection pool of addr like Close and additionally keeps the address out of the round-robin rotation until Unban: a later Get for the same address still returns a usable client, but Pick will not dial it. Use it when the cluster reports the member dead, so a caller holding a stale routing table cannot resurrect the address into the rotation.
type Config ¶
type Config struct {
BindAddr string
BindPort int
KeepAlivePeriod time.Duration
IdleClose time.Duration
TLS *tls.Config
}
Config is a composite type to bundle configuration parameters.
type ConnWrapper ¶
type HandlerFunc ¶
The HandlerFunc type is an adapter to allow the use of ordinary functions as RESP handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.
type ListenerWrapper ¶
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
ServeMux is an RESP command multiplexer. It is safe for concurrent use: handlers may be registered while the server is already accepting connections (services register their handlers after ListenAndServe).
func (*ServeMux) Handle ¶
Handle registers the handler for the given command. If a handler already exists for command, Handle panics.
func (*ServeMux) HandleFunc ¶
HandleFunc registers the handler function for the given command.
type ServeMuxWrapper ¶
type ServeMuxWrapper struct {
// contains filtered or unexported fields
}
func (*ServeMuxWrapper) HandleFunc ¶
func (m *ServeMuxWrapper) HandleFunc(command string, handler func(conn redcon.Conn, cmd redcon.Command))
HandleFunc registers the handler function for the given command.
type Server ¶
func New ¶
func New(config *Config, logger *flog.Logger, cp *checkpoint.Checkpoint) *Server
New creates and returns a new Server.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address addr.
func (*Server) ServeMux ¶
func (s *Server) ServeMux() *ServeMuxWrapper
func (*Server) SetPreConditionFunc ¶
func (*Server) Shutdown ¶
Shutdown gracefully shuts down the server without interrupting any active connections. Shutdown works by first closing all open listeners, then closing all idle connections, and then waiting indefinitely for connections to return to idle and then shut down. If the provided context expires before the shutdown is complete, Shutdown returns the context's error, otherwise it returns any error returned from closing the Server's underlying Listener(s).