redis

package
v0.0.0-...-f5047bd Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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

type ServerStatus struct {
	Valid   bool   `json:"valid"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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