barometer: update DMA's vendoring packages
[barometer.git] / src / dma / vendor / github.com / go-redis / redis / options.go
index 8a82d59..b6fabf3 100644 (file)
@@ -14,6 +14,17 @@ import (
        "github.com/go-redis/redis/internal/pool"
 )
 
+// Limiter is the interface of a rate limiter or a circuit breaker.
+type Limiter interface {
+       // Allow returns a nil if operation is allowed or an error otherwise.
+       // If operation is allowed client must report the result of operation
+       // whether is a success or a failure.
+       Allow() error
+       // ReportResult reports the result of previously allowed operation.
+       // nil indicates a success, non-nil error indicates a failure.
+       ReportResult(result error)
+}
+
 type Options struct {
        // The network type, either tcp or unix.
        // Default is tcp.
@@ -48,7 +59,7 @@ type Options struct {
        // Default is 5 seconds.
        DialTimeout time.Duration
        // Timeout for socket reads. If reached, commands will fail
-       // with a timeout instead of blocking.
+       // with a timeout instead of blocking. Use value -1 for no timeout and 0 for default.
        // Default is 3 seconds.
        ReadTimeout time.Duration
        // Timeout for socket writes. If reached, commands will fail
@@ -59,6 +70,12 @@ type Options struct {
        // Maximum number of socket connections.
        // Default is 10 connections per every CPU as reported by runtime.NumCPU.
        PoolSize int
+       // Minimum number of idle connections which is useful when establishing
+       // new connection is slow.
+       MinIdleConns int
+       // Connection age at which client retires (closes) the connection.
+       // Default is to not close aged connections.
+       MaxConnAge time.Duration
        // Amount of time client waits for connection if all connections
        // are busy before returning an error.
        // Default is ReadTimeout + 1 second.
@@ -69,7 +86,8 @@ type Options struct {
        IdleTimeout time.Duration
        // Frequency of idle checks made by idle connections reaper.
        // Default is 1 minute. -1 disables idle connections reaper,
-       // but idle connections are still discarded by the client.
+       // but idle connections are still discarded by the client
+       // if IdleTimeout is set.
        IdleCheckFrequency time.Duration
 
        // Enables read only queries on slave nodes.
@@ -83,6 +101,9 @@ func (opt *Options) init() {
        if opt.Network == "" {
                opt.Network = "tcp"
        }
+       if opt.Addr == "" {
+               opt.Addr = "localhost:6379"
+       }
        if opt.Dialer == nil {
                opt.Dialer = func() (net.Conn, error) {
                        netDialer := &net.Dialer{
@@ -196,6 +217,8 @@ func newConnPool(opt *Options) *pool.ConnPool {
        return pool.NewConnPool(&pool.Options{
                Dialer:             opt.Dialer,
                PoolSize:           opt.PoolSize,
+               MinIdleConns:       opt.MinIdleConns,
+               MaxConnAge:         opt.MaxConnAge,
                PoolTimeout:        opt.PoolTimeout,
                IdleTimeout:        opt.IdleTimeout,
                IdleCheckFrequency: opt.IdleCheckFrequency,