Avoid rebuilding Edu objects in worker mode (#4770)

In worker mode, on the federation sender, when we receive an edu for sending
over the replication socket, it is parsed into an Edu object. There is no point
extracting the contents of it so that we can then immediately build another Edu.
This commit is contained in:
Richard van der Hoff 2019-03-04 12:57:44 +00:00 committed by GitHub
parent 2c3548d9d8
commit 856c83f5f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 19 deletions

View file

@ -159,8 +159,12 @@ class FederationRemoteSendQueue(object):
# stream.
pass
def send_edu(self, destination, edu_type, content, key=None):
def build_and_send_edu(self, destination, edu_type, content, key=None):
"""As per TransactionQueue"""
if destination == self.server_name:
logger.info("Not sending EDU to ourselves")
return
pos = self._next_pos()
edu = Edu(
@ -465,15 +469,11 @@ def process_rows_for_federation(transaction_queue, rows):
for destination, edu_map in iteritems(buff.keyed_edus):
for key, edu in edu_map.items():
transaction_queue.send_edu(
edu.destination, edu.edu_type, edu.content, key=key,
)
transaction_queue.send_edu(edu, key)
for destination, edu_list in iteritems(buff.edus):
for edu in edu_list:
transaction_queue.send_edu(
edu.destination, edu.edu_type, edu.content, key=None,
)
transaction_queue.send_edu(edu, None)
for destination in buff.device_destinations:
transaction_queue.send_device_messages(destination)