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

Move property setting from ReplicationLayer to base classes #2977

Merged
merged 3 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions synapse/federation/federation_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@

class FederationBase(object):
def __init__(self, hs):
self.hs = hs

self.server_name = hs.hostname
self.keyring = hs.get_keyring()
self.spam_checker = hs.get_spam_checker()
self.store = hs.get_datastore()
self._clock = hs.get_clock()

@defer.inlineCallbacks
def _check_sigs_and_hash_and_fetch(self, origin, pdus, outlier=False,
Expand Down
1 change: 1 addition & 0 deletions synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, hs):
self._clear_tried_cache, 60 * 1000,
)
self.state = hs.get_state_handler()
self.transport_layer = hs.get_federation_transport_client()

def _clear_tried_cache(self):
"""Clear pdu_destination_tried cache"""
Expand Down
6 changes: 6 additions & 0 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
FederationBase,
event_from_pdu_json,
)

from synapse.federation.persistence import TransactionActions
from synapse.federation.units import Edu, Transaction
import synapse.metrics
from synapse.types import get_domain_from_id
Expand Down Expand Up @@ -56,6 +58,10 @@ def __init__(self, hs):
self._server_linearizer = async.Linearizer("fed_server")
self._transaction_linearizer = async.Linearizer("fed_txn_handler")

self.transaction_actions = TransactionActions(self.store)

self.handler = None

self.registry = hs.get_federation_registry()

# We cache responses to state queries, as they take a while and often
Expand Down
22 changes: 0 additions & 22 deletions synapse/federation/replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from .federation_client import FederationClient
from .federation_server import FederationServer

from .persistence import TransactionActions

import logging


Expand All @@ -47,26 +45,6 @@ class ReplicationLayer(FederationClient, FederationServer):
"""

def __init__(self, hs, transport_layer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we kill off the transport_layer param (and hence get rid of this whole constructor)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh in view of ea7b3c4 that's fine

self.server_name = hs.hostname

self.keyring = hs.get_keyring()

self.transport_layer = transport_layer

self.federation_client = self

self.store = hs.get_datastore()

self.handler = None
self.edu_handlers = {}
self.query_handlers = {}

self._clock = hs.get_clock()

self.transaction_actions = TransactionActions(self.store)

self.hs = hs

super(ReplicationLayer, self).__init__(hs)

def __str__(self):
Expand Down