File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -365,14 +365,26 @@ Connecting redis-py to the Sentinel instance(s) is easy. You can use a
365365Sentinel connection to discover the master and slaves network addresses:
366366
367367``` pycon
368- >>> from redis.sentinel import Sentinel
368+ >>> from redis import Sentinel
369369>>> sentinel = Sentinel([(' localhost' , 26379 )], socket_timeout = 0.1 )
370370>>> sentinel.discover_master(' mymaster' )
371371('127.0.0.1', 6379)
372372>>> sentinel.discover_slaves(' mymaster' )
373373[('127.0.0.1', 6380)]
374374```
375375
376+ To connect to a sentinel which uses SSL ([ see SSL
377+ connections] ( #ssl-connections ) for more examples of SSL configurations):
378+
379+ ``` pycon
380+ >>> from redis import Sentinel
381+ >>> sentinel = Sentinel([(' localhost' , 26379 )],
382+ ssl=True,
383+ ssl_ca_certs='/etc/ssl/certs/ca-certificates.crt')
384+ >>> sentinel.discover_master(' mymaster' )
385+ ('127.0.0.1', 6379)
386+ ```
387+
376388You can also create Redis client connections from a Sentinel instance.
377389You can connect to either the master (for write operations) or a slave
378390(for read-only operations).
Original file line number Diff line number Diff line change 66 SSLConnection ,
77 UnixDomainSocketConnection
88)
9+ from redis .sentinel import (
10+ Sentinel ,
11+ SentinelConnectionPool ,
12+ SentinelManagedConnection ,
13+ SentinelManagedSSLConnection ,
14+ )
915from redis .utils import from_url
1016from redis .exceptions import (
1117 AuthenticationError ,
@@ -51,6 +57,10 @@ def int_or_str(value):
5157 'Redis' ,
5258 'RedisError' ,
5359 'ResponseError' ,
60+ 'Sentinel' ,
61+ 'SentinelConnectionPool' ,
62+ 'SentinelManagedConnection' ,
63+ 'SentinelManagedSSLConnection' ,
5464 'SSLConnection' ,
5565 'StrictRedis' ,
5666 'TimeoutError' ,
Original file line number Diff line number Diff line change @@ -80,7 +80,9 @@ class SentinelConnectionPool(ConnectionPool):
8080
8181 def __init__ (self , service_name , sentinel_manager , ** kwargs ):
8282 kwargs ['connection_class' ] = kwargs .get (
83- 'connection_class' , SentinelManagedConnection )
83+ 'connection_class' ,
84+ SentinelManagedSSLConnection if kwargs .pop ('ssl' , False )
85+ else SentinelManagedConnection )
8486 self .is_master = kwargs .pop ('is_master' , True )
8587 self .check_connection = kwargs .pop ('check_connection' , False )
8688 super ().__init__ (** kwargs )
You can’t perform that action at this time.
0 commit comments