Add TLS configuration support for Universal Client

This commit is contained in:
Vadim Liman 2018-05-11 09:46:09 +03:00
parent 12c0262c75
commit 09b9a99666
3 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package redis
import ( import (
"context" "context"
"crypto/tls"
"errors" "errors"
"fmt" "fmt"
"math" "math"
@ -56,6 +57,8 @@ type ClusterOptions struct {
PoolTimeout time.Duration PoolTimeout time.Duration
IdleTimeout time.Duration IdleTimeout time.Duration
IdleCheckFrequency time.Duration IdleCheckFrequency time.Duration
TLSConfig *tls.Config
} }
func (opt *ClusterOptions) init() { func (opt *ClusterOptions) init() {
@ -117,6 +120,8 @@ func (opt *ClusterOptions) clientOptions() *Options {
IdleTimeout: opt.IdleTimeout, IdleTimeout: opt.IdleTimeout,
IdleCheckFrequency: disableIdleCheck, IdleCheckFrequency: disableIdleCheck,
TLSConfig: opt.TLSConfig,
} }
} }

View File

@ -1,6 +1,7 @@
package redis package redis
import ( import (
"crypto/tls"
"errors" "errors"
"net" "net"
"strings" "strings"
@ -38,6 +39,8 @@ type FailoverOptions struct {
PoolTimeout time.Duration PoolTimeout time.Duration
IdleTimeout time.Duration IdleTimeout time.Duration
IdleCheckFrequency time.Duration IdleCheckFrequency time.Duration
TLSConfig *tls.Config
} }
func (opt *FailoverOptions) options() *Options { func (opt *FailoverOptions) options() *Options {
@ -59,6 +62,8 @@ func (opt *FailoverOptions) options() *Options {
PoolTimeout: opt.PoolTimeout, PoolTimeout: opt.PoolTimeout,
IdleTimeout: opt.IdleTimeout, IdleTimeout: opt.IdleTimeout,
IdleCheckFrequency: opt.IdleCheckFrequency, IdleCheckFrequency: opt.IdleCheckFrequency,
TLSConfig: opt.TLSConfig,
} }
} }

View File

@ -1,6 +1,9 @@
package redis package redis
import "time" import (
"crypto/tls"
"time"
)
// UniversalOptions information is required by UniversalClient to establish // UniversalOptions information is required by UniversalClient to establish
// connections. // connections.
@ -37,6 +40,7 @@ type UniversalOptions struct {
PoolTimeout time.Duration PoolTimeout time.Duration
IdleTimeout time.Duration IdleTimeout time.Duration
IdleCheckFrequency time.Duration IdleCheckFrequency time.Duration
TLSConfig *tls.Config
} }
func (o *UniversalOptions) cluster() *ClusterOptions { func (o *UniversalOptions) cluster() *ClusterOptions {
@ -60,6 +64,7 @@ func (o *UniversalOptions) cluster() *ClusterOptions {
PoolTimeout: o.PoolTimeout, PoolTimeout: o.PoolTimeout,
IdleTimeout: o.IdleTimeout, IdleTimeout: o.IdleTimeout,
IdleCheckFrequency: o.IdleCheckFrequency, IdleCheckFrequency: o.IdleCheckFrequency,
TLSConfig: o.TLSConfig,
} }
} }
@ -83,6 +88,7 @@ func (o *UniversalOptions) failover() *FailoverOptions {
PoolTimeout: o.PoolTimeout, PoolTimeout: o.PoolTimeout,
IdleTimeout: o.IdleTimeout, IdleTimeout: o.IdleTimeout,
IdleCheckFrequency: o.IdleCheckFrequency, IdleCheckFrequency: o.IdleCheckFrequency,
TLSConfig: o.TLSConfig,
} }
} }
@ -106,6 +112,7 @@ func (o *UniversalOptions) simple() *Options {
PoolTimeout: o.PoolTimeout, PoolTimeout: o.PoolTimeout,
IdleTimeout: o.IdleTimeout, IdleTimeout: o.IdleTimeout,
IdleCheckFrequency: o.IdleCheckFrequency, IdleCheckFrequency: o.IdleCheckFrequency,
TLSConfig: o.TLSConfig,
} }
} }