redis

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigRootRedisConnection = "redis"
	DefaultDbIndex            = 0
)
View Source
const KeepTTL = redis.KeepTTL

KeepTTL is an option for Set command to keep key's existing TTL. For example:

rdb.Set(ctx, key, value, redis.KeepTTL)

Variables

View Source
var Module = &bootstrap.Module{
	Precedence: bootstrap.RedisPrecedence,
	Options: []fx.Option{
		fx.Provide(BindRedisProperties),
		fx.Provide(provideClientFactory),
		fx.Provide(provideDefaultClient),
		fx.Invoke(registerHealth),
	},
}

Functions

func GetUniversalOptions

func GetUniversalOptions(p *RedisProperties, opts ...ConnOptions) (*redis.UniversalOptions, error)

func NewRedisTrackingHook added in v0.14.0

func NewRedisTrackingHook(tracer opentracing.Tracer) *redisTracingHook

func Use

func Use()

Use Allow service to include this module in main()

Types

type Client

type Client interface {
	redis.UniversalClient
}

type ClientFactory

type ClientFactory interface {
	// New returns a newly created Client
	New(ctx context.Context, opts ...ClientOptions) (Client, error)

	// AddHooks add hooks to all Client already created and any future Client created via this interface
	// If the given hook also implments OptionsAwareHook, the method will be used to derive a hook instance and added to
	// coresponding client
	AddHooks(ctx context.Context, hooks ...redis.Hook)
}

func NewClientFactory

func NewClientFactory(opts ...FactoryOptions) ClientFactory

type ClientOption

type ClientOption struct {
	DbIndex int
}

type ClientOptions

type ClientOptions func(opt *ClientOption)

type ConnOptions

type ConnOptions func(opt *redis.UniversalOptions) error

ConnOptions options for connectivity by manipulating redis.UniversalOptions

type FactoryOption

type FactoryOption struct {
	Properties      RedisProperties
	TLSCertsManager certs.Manager
}

type FactoryOptions

type FactoryOptions func(opt *FactoryOption)

type OptionsAwareHook

type OptionsAwareHook interface {
	redis.Hook
	WithClientOption(*redis.UniversalOptions) redis.Hook
}

type RedisHealthIndicator

type RedisHealthIndicator struct {
	// contains filtered or unexported fields
}

func (*RedisHealthIndicator) Health

func (*RedisHealthIndicator) Name

func (i *RedisHealthIndicator) Name() string

type RedisProperties

type RedisProperties struct {
	// Either a single address or a seed list of host:port addresses
	// of cluster/sentinel nodes.
	Addresses utils.CommaSeparatedSlice `json:"addrs"`

	// Database to be selected after connecting to the server.
	// Only single-node and failover clients.
	DB int `json:"db"`

	// Common options.
	Username string `json:"username"`
	Password string `json:"password"`

	MaxRetries      int           `json:"max-retries"`
	MinRetryBackoff time.Duration `json:"min-retry-backoff"`
	MaxRetryBackoff time.Duration `json:"max-retry-backoff"`

	DialTimeout  time.Duration `json:"dial-timeout"`
	ReadTimeout  time.Duration `json:"read-timeout"`
	WriteTimeout time.Duration `json:"write-timeout"`

	PoolSize           int           `json:"pool-size"`
	MinIdleConns       int           `json:"min-idle-conns"`
	MaxConnAge         time.Duration `json:"max-conn-age"`
	PoolTimeout        time.Duration `json:"pool-timeout"`
	IdleTimeout        time.Duration `json:"idle-timeout"`
	IdleCheckFrequency time.Duration `json:"idle-check-frequency"`

	// TLS Properties for Redis
	TLS TLSProperties `json:"tls"`

	MaxRedirects   int  `json:"max-redirects"`
	ReadOnly       bool `json:"read-only"`
	RouteByLatency bool `json:"route-by-latency"`
	RouteRandomly  bool `json:"route-randomly"`

	// The sentinel master name.
	// Only failover clients.
	MasterName       string `json:"master-name"`
	SentinelPassword string `json:"sentinel-password"`
}

func BindRedisProperties

func BindRedisProperties(ctx *bootstrap.ApplicationContext) RedisProperties

type TLSProperties

type TLSProperties struct {
	Enabled bool                   `json:"enabled"`
	Certs   certs.SourceProperties `json:"certs"`
}

Jump to

Keyboard shortcuts

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