Merge pull request #762 from vliman/feature/tls_config_for_universal_client

Add TLS configuration support for Universal Client
This commit is contained in:
Vladimir Mihailenco 2018-05-11 11:33:01 +03:00 committed by GitHub
commit bc49453a24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

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

View File

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

View File

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