This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed
Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ from twisted.internet import protocol
2020from twisted .internet .defer import Deferred
2121
2222class RedisProtocol (protocol .Protocol ):
23- def publish (self , channel : str , message : bytes ): ...
23+ def publish (self , channel : str , message : bytes ) -> "Deferred[None]" : ...
2424 def ping (self ) -> "Deferred[None]" : ...
2525 def set (
2626 self ,
@@ -52,11 +52,14 @@ def lazyConnection(
5252 convertNumbers : bool = ...,
5353) -> RedisProtocol : ...
5454
55- class ConnectionHandler : ...
55+ # ConnectionHandler doesn't actually inherit from RedisProtocol, but it proxies
56+ # most methods to it via ConnectionHandler.__getattr__.
57+ class ConnectionHandler (RedisProtocol ):
58+ def disconnect (self ) -> "Deferred[None]" : ...
5659
5760class RedisFactory (protocol .ReconnectingClientFactory ):
5861 continueTrying : bool
59- handler : RedisProtocol
62+ handler : ConnectionHandler
6063 pool : List [RedisProtocol ]
6164 replyTimeout : Optional [int ]
6265 def __init__ (
Original file line number Diff line number Diff line change 2121from synapse .util import json_decoder , json_encoder
2222
2323if TYPE_CHECKING :
24- from txredisapi import RedisProtocol
24+ from txredisapi import ConnectionHandler
2525
2626 from synapse .server import HomeServer
2727
@@ -63,7 +63,7 @@ class ExternalCache:
6363 def __init__ (self , hs : "HomeServer" ):
6464 if hs .config .redis .redis_enabled :
6565 self ._redis_connection : Optional [
66- "RedisProtocol "
66+ "ConnectionHandler "
6767 ] = hs .get_outbound_redis_connection ()
6868 else :
6969 self ._redis_connection = None
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ class RedisSubscriber(txredisapi.SubscriberProtocol):
9393
9494 synapse_handler : "ReplicationCommandHandler"
9595 synapse_stream_name : str
96- synapse_outbound_redis_connection : txredisapi .RedisProtocol
96+ synapse_outbound_redis_connection : txredisapi .ConnectionHandler
9797
9898 def __init__ (self , * args : Any , ** kwargs : Any ):
9999 super ().__init__ (* args , ** kwargs )
@@ -313,7 +313,7 @@ class RedisDirectTcpReplicationClientFactory(SynapseRedisFactory):
313313 protocol = RedisSubscriber
314314
315315 def __init__ (
316- self , hs : "HomeServer" , outbound_redis_connection : txredisapi .RedisProtocol
316+ self , hs : "HomeServer" , outbound_redis_connection : txredisapi .ConnectionHandler
317317 ):
318318
319319 super ().__init__ (
@@ -353,7 +353,7 @@ def lazyConnection(
353353 reconnect : bool = True ,
354354 password : Optional [str ] = None ,
355355 replyTimeout : int = 30 ,
356- ) -> txredisapi .RedisProtocol :
356+ ) -> txredisapi .ConnectionHandler :
357357 """Creates a connection to Redis that is lazily set up and reconnects if the
358358 connections is lost.
359359 """
Original file line number Diff line number Diff line change 144144logger = logging .getLogger (__name__ )
145145
146146if TYPE_CHECKING :
147- from txredisapi import RedisProtocol
147+ from txredisapi import ConnectionHandler
148148
149149 from synapse .handlers .oidc import OidcHandler
150150 from synapse .handlers .saml import SamlHandler
@@ -808,7 +808,7 @@ def get_external_cache(self) -> ExternalCache:
808808 return ExternalCache (self )
809809
810810 @cache_in_self
811- def get_outbound_redis_connection (self ) -> "RedisProtocol " :
811+ def get_outbound_redis_connection (self ) -> "ConnectionHandler " :
812812 """
813813 The Redis connection used for replication.
814814
You can’t perform that action at this time.
0 commit comments