Skip to content

Commit

Permalink
Add possibility to overwrite redis client options
Browse files Browse the repository at this point in the history
  • Loading branch information
nicmue committed Oct 7, 2020
1 parent 419321a commit c81840c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions backend/redis/redis.go
Expand Up @@ -84,8 +84,8 @@ func init() {
}

// Client with environment based configuration
func Client() *redis.Client {
return CustomClient(&redis.Options{
func Client(overwriteOpts ...func(*redis.Options)) *redis.Client {
opts := &redis.Options{
Addr: cfg.Addrs[0],
Password: cfg.Password,
DB: cfg.DB,
Expand All @@ -101,7 +101,13 @@ func Client() *redis.Client {
PoolTimeout: cfg.PoolTimeout,
IdleTimeout: cfg.IdleTimeout,
IdleCheckFrequency: cfg.IdleCheckFrequency,
})
}

for _, o := range overwriteOpts {
o(opts)
}

return CustomClient(opts)
}

// CustomClient with passed configuration
Expand Down

0 comments on commit c81840c

Please sign in to comment.