Documentation ¶
Index ¶
- Variables
- type ClientPool
- func (c *ClientPool) FunctionLoadReplace(ctx context.Context, idx *uint8, code string) *redis.StringCmd
- func (c *ClientPool) GetClient(idx *uint8) *redis.Client
- func (c *ClientPool) GetCurrentClient() *redis.Client
- func (c *ClientPool) GetCurrentTurn() *uint8
- func (c *ClientPool) GetRedisServerStatus(ctx context.Context, idx uint8) *ServerStatus
- func (c *ClientPool) GetRedisServersStatus(ctx context.Context) map[uint8]ServerStatus
- func (c *ClientPool) InitRedisClientPool(servers *[]EnvRedisServer)
- type EnvRedisServer
- type EnvRedisServerDialer
- type EnvRedisServerWorker
- type ServerStatus
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRedisClientNil = errors.New("redis client nil")
View Source
var ErrRedisClientsNotAvailable = errors.New("redis client(s) not available")
View Source
var ServerTurn atomic.Uint32
Functions ¶
This section is empty.
Types ¶
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
func (*ClientPool) FunctionLoadReplace ¶
func (c *ClientPool) FunctionLoadReplace(ctx context.Context, idx *uint8, code string) *redis.StringCmd
func (*ClientPool) GetClient ¶
func (c *ClientPool) GetClient(idx *uint8) *redis.Client
func (*ClientPool) GetCurrentClient ¶
func (c *ClientPool) GetCurrentClient() *redis.Client
GetCurrentClient 获得当前活动 redis 客户端指针。如果没有活动客户端,则报 ErrRedisClientNil 错误。
func (*ClientPool) GetCurrentTurn ¶
func (c *ClientPool) GetCurrentTurn() *uint8
GetCurrentTurn 获得当前活动 redis 客户端顺序。如果没有活动客户端,则报 ErrRedisClientNil 错误。 注意!如果某个 Redis 服务器的权重大于1,则意味着该服务器将被询问多次。
func (*ClientPool) GetRedisServerStatus ¶
func (c *ClientPool) GetRedisServerStatus(ctx context.Context, idx uint8) *ServerStatus
func (*ClientPool) GetRedisServersStatus ¶
func (c *ClientPool) GetRedisServersStatus(ctx context.Context) map[uint8]ServerStatus
func (*ClientPool) InitRedisClientPool ¶
func (c *ClientPool) InitRedisClientPool(servers *[]EnvRedisServer)
type EnvRedisServer ¶
type EnvRedisServer struct { Host string `yaml:"Host,omitempty" default:"localhost"` Port uint16 `yaml:"Port,omitempty" default:"6379"` Username string `yaml:"Username,omitempty" default:""` Password string `yaml:"Password,omitempty" default:""` DB int `yaml:"DB,omitempty" default:"0" validate:"min=0,max=15"` Weight uint8 `yaml:"Weight,omitempty" default:"1" validate:"min=1,max=10"` Dialer *EnvRedisServerDialer `yaml:"Dialer,omitempty"` Worker *EnvRedisServerWorker `yaml:"Worker,omitempty"` }
func (*EnvRedisServer) GetDialerDefault ¶
func (e *EnvRedisServer) GetDialerDefault() *EnvRedisServerDialer
func (*EnvRedisServer) GetRedisOptions ¶
func (e *EnvRedisServer) GetRedisOptions() *redis.Options
func (*EnvRedisServer) GetWorkerDefault ¶
func (e *EnvRedisServer) GetWorkerDefault() *EnvRedisServerWorker
func (*EnvRedisServer) Validate ¶
func (e *EnvRedisServer) Validate() error
type EnvRedisServerDialer ¶
type EnvRedisServerDialer struct { KeepAlive uint8 `yaml:"KeepAlive,omitempty" default:"5" validate:"min=1,max=10"` Timeout uint8 `yaml:"Timeout,omitempty" default:"1" validate:"min=1,max=10"` }
func (*EnvRedisServerDialer) Validate ¶
func (e *EnvRedisServerDialer) Validate() error
type EnvRedisServerWorker ¶
type EnvRedisServerWorker struct {
Interval uint16 `yaml:"Interval,omitempty" default:"1000" validate:"min=100,max=60000"`
}
func (*EnvRedisServerWorker) Validate ¶
func (e *EnvRedisServerWorker) Validate() error
type ServerStatus ¶
Click to show internal directories.
Click to hide internal directories.