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

Commit

Permalink
Merge pull request #2978 from matrix-org/erikj/refactor_replication_l…
Browse files Browse the repository at this point in the history
…ayer

Remove ReplicationLayer and user Client/Server directly
  • Loading branch information
erikjohnston authored Mar 13, 2018
2 parents 5d8476d + cb9f8e5 commit 95cb401
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 33 deletions.
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_client().start_get_pdu_cache()
hs.get_federation_client().start_get_pdu_cache()

register_memory_metrics(hs)

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_server(),
handler=hs.get_federation_server(),
authenticator=authenticator,
ratelimiter=ratelimiter,
server_name=hs.hostname,
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class DeviceListEduUpdater(object):

def __init__(self, hs, device_handler):
self.store = hs.get_datastore()
self.federation = hs.get_replication_client()
self.federation = hs.get_federation_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_client()
self.federation = hs.get_federation_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_client()
self.federation = hs.get_federation_client()
self.device_handler = hs.get_device_handler()
self.is_mine = hs.is_mine
self.clock = hs.get_clock()
Expand Down
2 changes: 1 addition & 1 deletion 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_client()
self.replication_layer = hs.get_federation_client()
self.state_handler = hs.get_state_handler()
self.server_name = hs.hostname
self.keyring = hs.get_keyring()
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_client()
self.federation = hs.get_federation_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_client()
repl_layer = self.hs.get_federation_client()
if search_filter:
# We can't cache when asking for search
return repl_layer.get_public_rooms(
Expand Down
8 changes: 4 additions & 4 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def build_DEPENDENCY(self)
DEPENDENCIES = [
'http_client',
'db_pool',
'replication_client',
'replication_server',
'federation_client',
'federation_server',
'handlers',
'v1auth',
'auth',
Expand Down Expand Up @@ -199,10 +199,10 @@ def get_distributor(self):
def get_ratelimiter(self):
return self.ratelimiter

def build_replication_client(self):
def build_federation_client(self):
return FederationClient(self)

def build_replication_server(self):
def build_federation_server(self):
return FederationServer(self)

def build_handlers(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def register_query_handler(query_type, handler):
hs = yield setup_test_homeserver(
http_client=None,
resource_for_federation=Mock(),
replication_client=self.mock_federation,
federation_client=self.mock_federation,
federation_registry=self.mock_registry,
)
hs.handlers = DirectoryHandlers(hs)
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, *args, **kwargs):
def setUp(self):
self.hs = yield utils.setup_test_homeserver(
handlers=None,
replication_client=mock.Mock(),
federation_client=mock.Mock(),
)
self.handler = synapse.handlers.e2e_keys.E2eKeysHandler(self.hs)

Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def register_query_handler(query_type, handler):
http_client=None,
handlers=None,
resource_for_federation=Mock(),
replication_client=self.mock_federation,
replication_server=Mock(),
federation_client=self.mock_federation,
federation_server=Mock(),
federation_registry=self.mock_registry,
ratelimiter=NonCallableMock(spec_set=[
"send_message",
Expand Down
2 changes: 1 addition & 1 deletion tests/replication/slave/storage/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def setUp(self):
self.hs = yield setup_test_homeserver(
"blue",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=[
"send_message",
]),
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/v1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def setUp(self):

hs = yield setup_test_homeserver(
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=[
"send_message",
]),
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/v1/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setUp(self):
http_client=None,
resource_for_client=self.mock_resource,
federation=Mock(),
replication_client=Mock(),
federation_client=Mock(),
profile_handler=self.mock_handler
)

Expand Down
16 changes: 8 additions & 8 deletions tests/rest/client/v1/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down Expand Up @@ -409,7 +409,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down Expand Up @@ -493,7 +493,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down Expand Up @@ -582,7 +582,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down Expand Up @@ -697,7 +697,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down Expand Up @@ -829,7 +829,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down Expand Up @@ -929,7 +929,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=[
"send_message",
]),
Expand Down Expand Up @@ -1003,7 +1003,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
"red",
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["send_message"]),
)
self.ratelimiter = hs.get_ratelimiter()
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/v1/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def setUp(self):
"red",
clock=self.clock,
http_client=None,
replication_client=Mock(),
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=[
"send_message",
]),
Expand Down
10 changes: 5 additions & 5 deletions tests/storage/test_appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
config=config,
federation_sender=Mock(),
replication_client=Mock(),
federation_client=Mock(),
)

self.as_token = "token1"
Expand Down Expand Up @@ -119,7 +119,7 @@ def setUp(self):
hs = yield setup_test_homeserver(
config=config,
federation_sender=Mock(),
replication_client=Mock(),
federation_client=Mock(),
)
self.db_pool = hs.get_db_pool()

Expand Down Expand Up @@ -455,7 +455,7 @@ def test_unique_works(self):
config=config,
datastore=Mock(),
federation_sender=Mock(),
replication_client=Mock(),
federation_client=Mock(),
)

ApplicationServiceStore(None, hs)
Expand All @@ -473,7 +473,7 @@ def test_duplicate_ids(self):
config=config,
datastore=Mock(),
federation_sender=Mock(),
replication_client=Mock(),
federation_client=Mock(),
)

with self.assertRaises(ConfigError) as cm:
Expand All @@ -497,7 +497,7 @@ def test_duplicate_as_tokens(self):
config=config,
datastore=Mock(),
federation_sender=Mock(),
replication_client=Mock(),
federation_client=Mock(),
)

with self.assertRaises(ConfigError) as cm:
Expand Down

0 comments on commit 95cb401

Please sign in to comment.