Skip to content

Commit

Permalink
Drive by: Replace "USER_IP" with the 'constant' defined in the comman…
Browse files Browse the repository at this point in the history
…d itself(UserIpCommand.NAME)
  • Loading branch information
realtyem committed Oct 12, 2023
1 parent 45e5a3d commit 92ebde4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion synapse/replication/tcp/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __init__(self, hs: "HomeServer"):
self._should_insert_client_ips = hs.get_instance_name() == "master"

if self._is_master or self._should_insert_client_ips:
self.subscribe_to_channel("USER_IP")
self.subscribe_to_channel(UserIpCommand.NAME)

if hs.config.redis.redis_enabled:
self._notifier.add_lock_released_callback(self.on_lock_released)
Expand Down
8 changes: 4 additions & 4 deletions tests/replication/tcp/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from twisted.internet import defer

from synapse.replication.tcp.commands import PositionCommand
from synapse.replication.tcp.commands import PositionCommand, UserIpCommand

from tests.replication._base import BaseMultiWorkerStreamTestCase

Expand All @@ -24,7 +24,7 @@ def test_subscribed_to_enough_redis_channels(self) -> None:
# The default main process is subscribed to the USER_IP channel.
self.assertCountEqual(
self.hs.get_replication_command_handler()._channels_to_subscribe_to,
["USER_IP"],
[UserIpCommand.NAME],
)

def test_background_worker_subscribed_to_user_ip(self) -> None:
Expand All @@ -38,7 +38,7 @@ def test_background_worker_subscribed_to_user_ip(self) -> None:
},
)
self.assertIn(
"USER_IP",
UserIpCommand.NAME,
worker1.get_replication_command_handler()._channels_to_subscribe_to,
)

Expand All @@ -62,7 +62,7 @@ def test_non_background_worker_not_subscribed_to_user_ip(self) -> None:
},
)
self.assertNotIn(
"USER_IP",
UserIpCommand.NAME,
worker2.get_replication_command_handler()._channels_to_subscribe_to,
)

Expand Down

0 comments on commit 92ebde4

Please sign in to comment.