-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow running sendToDevice on workers #9044
Changes from 22 commits
8f7e6b7
c132b39
691c373
124f415
e81d693
40d9869
6da60bf
7386f09
08a4f88
1236ac3
248832e
811cb59
eb6121a
7d43cb7
5420f01
36f0d2b
9a91c2d
82286cc
d371d96
fc38115
2667875
171f360
867a21f
07f2d9a
14624e7
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Support routing edu's to multiple instances. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add experimental support for handling and persistence of to-device messages to happen on worker processes |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -45,11 +45,25 @@ def __init__(self, hs: "HomeServer"): | |||||
self.store = hs.get_datastore() | ||||||
self.notifier = hs.get_notifier() | ||||||
self.is_mine = hs.is_mine | ||||||
self.federation = hs.get_federation_sender() | ||||||
|
||||||
hs.get_federation_registry().register_edu_handler( | ||||||
"m.direct_to_device", self.on_direct_to_device_edu | ||||||
) | ||||||
# We only need to poke the federation sender explicitly if its on the | ||||||
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.
Suggested change
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 it work if it's on a different instance? 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. I've expanded the comment to:
|
||||||
# same instance. Other federation sender instances will get notified by | ||||||
# the `generic_worker` when it sees it in the to-device replication | ||||||
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. sorry, what's the 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. Specifically the federation sender in the |
||||||
# stream. | ||||||
self.federation_sender = None | ||||||
if hs.should_send_federation(): | ||||||
self.federation_sender = hs.get_federation_sender() | ||||||
|
||||||
# If we can handle the to device EDUs we do so, otherwise we route them | ||||||
# to the appropriate worker. | ||||||
if hs.get_instance_name() in hs.config.worker.writers.to_device: | ||||||
hs.get_federation_registry().register_edu_handler( | ||||||
"m.direct_to_device", self.on_direct_to_device_edu | ||||||
) | ||||||
else: | ||||||
hs.get_federation_registry().register_instances_for_edu( | ||||||
"m.direct_to_device", hs.config.worker.writers.to_device, | ||||||
) | ||||||
|
||||||
# The handler to call when we think a user's device list might be out of | ||||||
# sync. We do all device list resyncing on the master instance, so if | ||||||
|
@@ -204,7 +218,8 @@ async def send_device_message( | |||||
) | ||||||
|
||||||
log_kv({"remote_messages": remote_messages}) | ||||||
for destination in remote_messages.keys(): | ||||||
# Enqueue a new federation transaction to send the new | ||||||
# device messages to each remote destination. | ||||||
self.federation.send_device_messages(destination) | ||||||
if self.federation_sender: | ||||||
for destination in remote_messages.keys(): | ||||||
# Enqueue a new federation transaction to send the new | ||||||
# device messages to each remote destination. | ||||||
self.federation_sender.send_device_messages(destination) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably lost?