Skip to content

Commit bc49453

Browse files
authored
Merge pull request #762 from vliman/feature/tls_config_for_universal_client
Add TLS configuration support for Universal Client
2 parents 12c0262 + 09b9a99 commit bc49453

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

cluster.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package redis
22

33
import (
44
"context"
5+
"crypto/tls"
56
"errors"
67
"fmt"
78
"math"
@@ -56,6 +57,8 @@ type ClusterOptions struct {
5657
PoolTimeout time.Duration
5758
IdleTimeout time.Duration
5859
IdleCheckFrequency time.Duration
60+
61+
TLSConfig *tls.Config
5962
}
6063

6164
func (opt *ClusterOptions) init() {
@@ -117,6 +120,8 @@ func (opt *ClusterOptions) clientOptions() *Options {
117120
IdleTimeout: opt.IdleTimeout,
118121

119122
IdleCheckFrequency: disableIdleCheck,
123+
124+
TLSConfig: opt.TLSConfig,
120125
}
121126
}
122127

sentinel.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package redis
22

33
import (
4+
"crypto/tls"
45
"errors"
56
"net"
67
"strings"
@@ -38,6 +39,8 @@ type FailoverOptions struct {
3839
PoolTimeout time.Duration
3940
IdleTimeout time.Duration
4041
IdleCheckFrequency time.Duration
42+
43+
TLSConfig *tls.Config
4144
}
4245

4346
func (opt *FailoverOptions) options() *Options {
@@ -59,6 +62,8 @@ func (opt *FailoverOptions) options() *Options {
5962
PoolTimeout: opt.PoolTimeout,
6063
IdleTimeout: opt.IdleTimeout,
6164
IdleCheckFrequency: opt.IdleCheckFrequency,
65+
66+
TLSConfig: opt.TLSConfig,
6267
}
6368
}
6469

universal.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package redis
22

3-
import "time"
3+
import (
4+
"crypto/tls"
5+
"time"
6+
)
47

58
// UniversalOptions information is required by UniversalClient to establish
69
// connections.
@@ -37,6 +40,7 @@ type UniversalOptions struct {
3740
PoolTimeout time.Duration
3841
IdleTimeout time.Duration
3942
IdleCheckFrequency time.Duration
43+
TLSConfig *tls.Config
4044
}
4145

4246
func (o *UniversalOptions) cluster() *ClusterOptions {
@@ -60,6 +64,7 @@ func (o *UniversalOptions) cluster() *ClusterOptions {
6064
PoolTimeout: o.PoolTimeout,
6165
IdleTimeout: o.IdleTimeout,
6266
IdleCheckFrequency: o.IdleCheckFrequency,
67+
TLSConfig: o.TLSConfig,
6368
}
6469
}
6570

@@ -83,6 +88,7 @@ func (o *UniversalOptions) failover() *FailoverOptions {
8388
PoolTimeout: o.PoolTimeout,
8489
IdleTimeout: o.IdleTimeout,
8590
IdleCheckFrequency: o.IdleCheckFrequency,
91+
TLSConfig: o.TLSConfig,
8692
}
8793
}
8894

@@ -106,6 +112,7 @@ func (o *UniversalOptions) simple() *Options {
106112
PoolTimeout: o.PoolTimeout,
107113
IdleTimeout: o.IdleTimeout,
108114
IdleCheckFrequency: o.IdleCheckFrequency,
115+
TLSConfig: o.TLSConfig,
109116
}
110117
}
111118

0 commit comments

Comments
 (0)