@@ -20,13 +20,16 @@ class SentinelClient
20
20
#
21
21
# @property endpoints [Array(Endpoint)] The list of sentinel endpoints.
22
22
# @property master_name [String] The name of the master instance, defaults to 'mymaster'.
23
+ # @property master_options [Hash] Connection options for master.
23
24
# @property role [Symbol] The role of the instance that you want to connect to, either `:master` or `:slave`.
24
- # @property protocol [Protocol] The protocol to use when connecting to the actual Redis server, defaults to {Protocol::RESP2}.
25
- def initialize ( endpoints , master_name : DEFAULT_MASTER_NAME , role : :master , protocol : Protocol ::RESP2 , **options )
25
+ def initialize ( endpoints , master_name : DEFAULT_MASTER_NAME , master_options : nil , role : :master , **options )
26
26
@endpoints = endpoints
27
27
@master_name = master_name
28
+ @master_options = master_options
28
29
@role = role
29
- @protocol = protocol
30
+
31
+ @ssl = !!master_options &.key? ( :ssl_context )
32
+ @scheme = "redis#{ @ssl ? 's' : '' } "
30
33
31
34
# A cache of sentinel connections.
32
35
@sentinels = { }
@@ -88,8 +91,8 @@ def resolve_master
88
91
rescue Errno ::ECONNREFUSED
89
92
next
90
93
end
91
-
92
- return Endpoint . remote ( address [ 0 ] , address [ 1 ] ) if address
94
+
95
+ return Endpoint . for ( @scheme , address [ 0 ] , port : address [ 1 ] , ** @master_options ) if address
93
96
end
94
97
95
98
return nil
@@ -107,7 +110,7 @@ def resolve_slave
107
110
next if slaves . empty?
108
111
109
112
slave = select_slave ( slaves )
110
- return Endpoint . remote ( slave [ "ip" ] , slave [ "port" ] )
113
+ return Endpoint . for ( @scheme , slave [ "ip" ] , port : slave [ "port" ] , ** @master_options )
111
114
end
112
115
113
116
return nil
@@ -116,7 +119,6 @@ def resolve_slave
116
119
protected
117
120
118
121
def assign_default_tags ( tags )
119
- tags [ :protocol ] = @protocol . to_s
120
122
end
121
123
122
124
# Override the parent method. The only difference is that this one needs to resolve the master/slave address.
@@ -127,8 +129,8 @@ def make_pool(**options)
127
129
endpoint = resolve_address
128
130
peer = endpoint . connect
129
131
stream = ::IO ::Stream ( peer )
130
-
131
- @ protocol. client ( stream )
132
+
133
+ endpoint . protocol . client ( stream )
132
134
end
133
135
end
134
136
0 commit comments