Skip to content

Commit

Permalink
Merge pull request #180 from heroku/allow-redis-pools-to-wait
Browse files Browse the repository at this point in the history
allow redigo pools to wait
  • Loading branch information
voidlock authored Oct 18, 2022
2 parents 0e73480 + 47f5f09 commit c12028c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmdutil/redispool/redispool.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ type Config struct {
// When set to zero, aliveness is not checked.
IdleProbeInterval time.Duration `env:"REDIS_IDLE_PROBE_INTERVAL,default=0s"`

// Wait when true and the pool is at the MaxActiveConns limit, calls to Get()
// wait for a connection to be returned to the pool before returning.
Wait bool `env:"REDIS_WAIT,default=false"`

// AttachmentNames is an optional configuration which allows to set up
// connection pools to each redis attachment using the Pools() function. The
// same configuration parameters apply for each pool, except the URL which is
Expand Down Expand Up @@ -104,6 +108,7 @@ func newPool(cfg Config) *redis.Pool {
MaxActive: cfg.MaxActiveConns,
MaxConnLifetime: cfg.MaxConnLifetime,
IdleTimeout: cfg.IdleTimeout,
Wait: cfg.Wait,
TestOnBorrow: func(conn redis.Conn, t time.Time) error {
var err error
if cfg.IdleProbeInterval > 0 && time.Since(t) > cfg.IdleProbeInterval {
Expand Down

0 comments on commit c12028c

Please sign in to comment.