Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 3bf973e

Browse files
authored
Remove unused class: DirectTcpReplicationClientFactory. (#15272)
1 parent 121fce7 commit 3bf973e

File tree

2 files changed

+1
-51
lines changed

2 files changed

+1
-51
lines changed

changelog.d/15272.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove unused class `DirectTcpReplicationClientFactory`.

synapse/replication/tcp/client.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@
1818

1919
from twisted.internet import defer
2020
from twisted.internet.defer import Deferred
21-
from twisted.internet.interfaces import IAddress, IConnector
22-
from twisted.internet.protocol import ReconnectingClientFactory
23-
from twisted.python.failure import Failure
2421

2522
from synapse.api.constants import EventTypes, Membership, ReceiptTypes
2623
from synapse.federation import send_queue
2724
from synapse.federation.sender import FederationSender
2825
from synapse.logging.context import PreserveLoggingContext, make_deferred_yieldable
2926
from synapse.metrics.background_process_metrics import run_as_background_process
30-
from synapse.replication.tcp.protocol import ClientReplicationStreamProtocol
3127
from synapse.replication.tcp.streams import (
3228
AccountDataStream,
3329
DeviceListsStream,
@@ -53,7 +49,6 @@
5349
from synapse.util.metrics import Measure
5450

5551
if TYPE_CHECKING:
56-
from synapse.replication.tcp.handler import ReplicationCommandHandler
5752
from synapse.server import HomeServer
5853

5954
logger = logging.getLogger(__name__)
@@ -62,52 +57,6 @@
6257
_WAIT_FOR_REPLICATION_TIMEOUT_SECONDS = 5
6358

6459

65-
class DirectTcpReplicationClientFactory(ReconnectingClientFactory):
66-
"""Factory for building connections to the master. Will reconnect if the
67-
connection is lost.
68-
69-
Accepts a handler that is passed to `ClientReplicationStreamProtocol`.
70-
"""
71-
72-
initialDelay = 0.1
73-
maxDelay = 1 # Try at least once every N seconds
74-
75-
def __init__(
76-
self,
77-
hs: "HomeServer",
78-
client_name: str,
79-
command_handler: "ReplicationCommandHandler",
80-
):
81-
self.client_name = client_name
82-
self.command_handler = command_handler
83-
self.server_name = hs.config.server.server_name
84-
self.hs = hs
85-
self._clock = hs.get_clock() # As self.clock is defined in super class
86-
87-
hs.get_reactor().addSystemEventTrigger("before", "shutdown", self.stopTrying)
88-
89-
def startedConnecting(self, connector: IConnector) -> None:
90-
logger.info("Connecting to replication: %r", connector.getDestination())
91-
92-
def buildProtocol(self, addr: IAddress) -> ClientReplicationStreamProtocol:
93-
logger.info("Connected to replication: %r", addr)
94-
return ClientReplicationStreamProtocol(
95-
self.hs,
96-
self.client_name,
97-
self.server_name,
98-
self._clock,
99-
self.command_handler,
100-
)
101-
102-
def clientConnectionLost(self, connector: IConnector, reason: Failure) -> None:
103-
logger.error("Lost replication conn: %r", reason)
104-
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
105-
106-
def clientConnectionFailed(self, connector: IConnector, reason: Failure) -> None:
107-
logger.error("Failed to connect to replication: %r", reason)
108-
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
109-
110-
11160
class ReplicationDataHandler:
11261
"""Handles incoming stream updates from replication.
11362

0 commit comments

Comments
 (0)