redis

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeSuccess     = "Success"
	CodeFail        = "Fail"
	CodeNotFound    = "NotFound"
	CodeInvalidType = "InvalidType"
)

Variables

View Source
var (
	ReceivedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "bucketeer",
			Subsystem: "redis",
			Name:      "received_total",
			Help:      "Total number of received commands.",
		}, []string{"version", "server", "command"})

	HandledCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "bucketeer",
			Subsystem: "redis",
			Name:      "handled_total",
			Help:      "Total number of completed commands.",
		}, []string{"version", "server", "command", "code"})

	HandledHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "bucketeer",
			Subsystem: "redis",
			Name:      "handling_seconds",
			Help:      "Histogram of command response latency (seconds).",
			Buckets:   prometheus.DefBuckets,
		}, []string{"version", "server", "command", "code"})
)
View Source
var ErrNil = redis.ErrNil

Functions

func RegisterMetrics

func RegisterMetrics(r metrics.Registerer, version, server string, stater PoolStater)

Types

type Cluster

type Cluster interface {
	Get(opts ...ConnectionOptions) redis.Conn
	Check(context.Context) health.Status
	Stats() PoolStats
	Close() error
}

func NewCluster

func NewCluster(nodes []string, opts ...Option) (Cluster, error)

type ConnectionOptions

type ConnectionOptions func(*connectionOptions)

func WithReadOnly

func WithReadOnly() ConnectionOptions

func WithRetry

func WithRetry(retries int, tryAgainDelay time.Duration) ConnectionOptions

func WithoutRetry

func WithoutRetry() ConnectionOptions

type Option

type Option func(*options)

func WithDialConnectTimeout

func WithDialConnectTimeout(timeout time.Duration) Option

func WithDialPassword

func WithDialPassword(password string) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMetrics

func WithMetrics(r metrics.Registerer) Option

func WithPoolIdleTimeout

func WithPoolIdleTimeout(timeout time.Duration) Option

func WithPoolMaxActive

func WithPoolMaxActive(num int) Option

func WithPoolMaxIdle

func WithPoolMaxIdle(num int) Option

func WithServerName

func WithServerName(serverName string) Option

type PoolStater

type PoolStater interface {
	Stats() PoolStats
}

type PoolStats

type PoolStats interface {
	ActiveCount() int
	IdleCount() int
}

Directories

Path Synopsis
v3
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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