-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Move server command handling out of TCP protocol #7187
Changes from 11 commits
e6c25e0
cadb3f5
dd93e91
1d00a74
525a47d
8a6a680
ad2a80a
8d81fd2
984c959
9cc5698
3653d03
ad2beda
27e4d2b
2190027
7b2af21
ffdf38c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,18 +42,17 @@ class ReplicationStreamProtocolFactory(Factory): | |
| """ | ||
|
|
||
| def __init__(self, hs): | ||
| self.handler = hs.get_tcp_replication() | ||
| self.command_handler = hs.get_tcp_replication() | ||
| self.clock = hs.get_clock() | ||
| self.server_name = hs.config.server_name | ||
| self.hs = hs | ||
|
|
||
| # Ensure the replication streamer is started if we register a | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does this "if we register a replication server endpoint" relate to this bit of code?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, you'd always do something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The subtlety here is that we only really want to start this if we configure a replication listener. I guess we could put this in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok so what you're saying is:
which is fine, but please can you make the comment say so? :) |
||
| # replication server endpoint. | ||
| hs.get_replication_streamer() | ||
|
|
||
| def buildProtocol(self, addr): | ||
| return ServerReplicationStreamProtocol( | ||
| self.server_name, self.clock, self.handler | ||
| self.server_name, self.clock, self.command_handler | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -94,7 +93,7 @@ def __init__(self, hs): | |
| self.is_looping = False | ||
| self.pending_updates = False | ||
|
|
||
| self.client = hs.get_tcp_replication() | ||
| self.command_handler = hs.get_tcp_replication() | ||
|
|
||
| def get_streams(self) -> Dict[str, Stream]: | ||
| """Get a mapp from stream name to stream instance. | ||
|
|
@@ -108,7 +107,7 @@ def on_notifier_poke(self): | |
| This should get called each time new data is available, even if it | ||
| is currently being executed, so that nothing gets missed | ||
| """ | ||
| if not self.client.connected(): | ||
| if not self.command_handler.connected(): | ||
| # Don't bother if nothing is listening. We still need to advance | ||
| # the stream tokens otherwise they'll fall beihind forever | ||
| for stream in self.streams: | ||
|
|
@@ -183,7 +182,9 @@ async def _run_notifier_loop(self): | |
|
|
||
| for token, row in batched_updates: | ||
| try: | ||
| self.client.stream_update(stream.NAME, token, row) | ||
| self.command_handler.stream_update( | ||
| stream.NAME, token, row | ||
| ) | ||
| except Exception: | ||
| logger.exception("Failed to replicate") | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.