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

Remove ReplicationLayer and user Client/Server directly #2978

Merged
merged 8 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
2 changes: 1 addition & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def start():
hs.get_state_handler().start_caching()
hs.get_datastore().start_profiling()
hs.get_datastore().start_doing_background_updates()
hs.get_replication_layer().start_get_pdu_cache()
hs.get_replication_client().start_get_pdu_cache()

register_memory_metrics(hs)

Expand Down
10 changes: 1 addition & 9 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,19 @@ def __init__(self, hs):
super(FederationServer, self).__init__(hs)

self.auth = hs.get_auth()
self.handler = hs.get_handlers().federation_handler

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
# come in waves.
self._state_resp_cache = ResponseCache(hs, timeout_ms=30000)

def set_handler(self, handler):
"""Sets the handler that the replication layer will use to communicate
receipt of new PDUs from other home servers. The required methods are
documented on :py:class:`.ReplicationHandler`.
"""
self.handler = handler

@defer.inlineCallbacks
@log_function
def on_backfill_request(self, origin, room_id, versions, limit):
Expand Down
2 changes: 1 addition & 1 deletion synapse/federation/transport/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ def on_POST(self, origin, content, query):
def register_servlets(hs, resource, authenticator, ratelimiter):
for servletclass in FEDERATION_SERVLET_CLASSES:
servletclass(
handler=hs.get_replication_layer(),
handler=hs.get_replication_server(),
authenticator=authenticator,
ratelimiter=ratelimiter,
server_name=hs.hostname,
Expand Down
3 changes: 1 addition & 2 deletions synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(self, hs):
self.state = hs.get_state_handler()
self._auth_handler = hs.get_auth_handler()
self.federation_sender = hs.get_federation_sender()
self.federation = hs.get_replication_layer()

self._edu_updater = DeviceListEduUpdater(hs, self)

Expand Down Expand Up @@ -432,7 +431,7 @@ class DeviceListEduUpdater(object):

def __init__(self, hs, device_handler):
self.store = hs.get_datastore()
self.federation = hs.get_replication_layer()
self.federation = hs.get_replication_client()
self.clock = hs.get_clock()
self.device_handler = device_handler

Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, hs):
self.appservice_handler = hs.get_application_service_handler()
self.event_creation_handler = hs.get_event_creation_handler()

self.federation = hs.get_replication_layer()
self.federation = hs.get_replication_client()
hs.get_federation_registry().register_query_handler(
"directory", self.on_directory_query
)
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class E2eKeysHandler(object):
def __init__(self, hs):
self.store = hs.get_datastore()
self.federation = hs.get_replication_layer()
self.federation = hs.get_replication_client()
self.device_handler = hs.get_device_handler()
self.is_mine = hs.is_mine
self.clock = hs.get_clock()
Expand Down
4 changes: 1 addition & 3 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, hs):
self.hs = hs

self.store = hs.get_datastore()
self.replication_layer = hs.get_replication_layer()
self.replication_layer = hs.get_replication_client()
self.state_handler = hs.get_state_handler()
self.server_name = hs.hostname
self.keyring = hs.get_keyring()
Expand All @@ -78,8 +78,6 @@ def __init__(self, hs):
self.spam_checker = hs.get_spam_checker()
self.event_creation_handler = hs.get_event_creation_handler()

self.replication_layer.set_handler(self)

# When joining a room we need to queue any events for that room up
self.room_queues = {}
self._room_pdu_linearizer = Linearizer("fed_room_pdu")
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def __init__(self, hs):
self.store = hs.get_datastore()
self.wheel_timer = WheelTimer()
self.notifier = hs.get_notifier()
self.replication = hs.get_replication_layer()
self.federation = hs.get_federation_sender()

self.state = hs.get_state_handler()
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ProfileHandler(BaseHandler):
def __init__(self, hs):
super(ProfileHandler, self).__init__(hs)

self.federation = hs.get_replication_layer()
self.federation = hs.get_replication_client()
hs.get_federation_registry().register_query_handler(
"profile", self.on_profile_query
)
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/room_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def get_remote_public_room_list(self, server_name, limit=None, since_token=None,
def _get_remote_list_cached(self, server_name, limit=None, since_token=None,
search_filter=None, include_all_networks=False,
third_party_instance_id=None,):
repl_layer = self.hs.get_replication_layer()
repl_layer = self.hs.get_replication_client()
if search_filter:
# We can't cache when asking for search
return repl_layer.get_public_rooms(
Expand Down
3 changes: 1 addition & 2 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(self, hs):
self.registration_handler = hs.get_handlers().registration_handler
self.profile_handler = hs.get_profile_handler()
self.event_creation_hander = hs.get_event_creation_handler()
self.replication_layer = hs.get_replication_layer()

self.member_linearizer = Linearizer(name="member")

Expand Down Expand Up @@ -212,7 +211,7 @@ def _update_membership(
# if this is a join with a 3pid signature, we may need to turn a 3pid
# invite into a normal invite before we can handle the join.
if third_party_signed is not None:
yield self.replication_layer.exchange_third_party_invite(
yield self.federation_handler.exchange_third_party_invite(
third_party_signed["sender"],
target.to_string(),
room_id,
Expand Down
13 changes: 9 additions & 4 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
from synapse.crypto.keyring import Keyring
from synapse.events.builder import EventBuilderFactory
from synapse.events.spamcheck import SpamChecker
from synapse.federation import initialize_http_replication
from synapse.federation.federation_client import FederationClient
from synapse.federation.federation_server import FederationServer
from synapse.federation.send_queue import FederationRemoteSendQueue
from synapse.federation.federation_server import FederationHandlerRegistry
from synapse.federation.transport.client import TransportLayerClient
Expand Down Expand Up @@ -100,7 +101,8 @@ def build_DEPENDENCY(self)
DEPENDENCIES = [
'http_client',
'db_pool',
'replication_layer',
'replication_client',
Copy link
Member

Choose a reason for hiding this comment

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

why is it called replication client/server rather than federation client/server? I find the whole thing confusing.

'replication_server',
'handlers',
'v1auth',
'auth',
Expand Down Expand Up @@ -197,8 +199,11 @@ def get_distributor(self):
def get_ratelimiter(self):
return self.ratelimiter

def build_replication_layer(self):
return initialize_http_replication(self)
def build_replication_client(self):
return FederationClient(self)

def build_replication_server(self):
return FederationServer(self)

def build_handlers(self):
return Handlers(self)
Expand Down