mirror of
https://github.com/element-hq/synapse
synced 2024-09-01 01:40:20 +00:00
Merge pull request #2978 from matrix-org/erikj/refactor_replication_layer
Remove ReplicationLayer and user Client/Server directly
This commit is contained in:
commit
95cb401ae0
18 changed files with 33 additions and 33 deletions
|
@ -348,7 +348,7 @@ def setup(config_options):
|
|||
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)
|
||||
|
||||
|
|
|
@ -1190,7 +1190,7 @@ GROUP_ATTESTATION_SERVLET_CLASSES = (
|
|||
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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class DirectoryHandler(BaseHandler):
|
|||
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
|
||||
)
|
||||
|
|
|
@ -32,7 +32,7 @@ logger = logging.getLogger(__name__)
|
|||
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()
|
||||
|
|
|
@ -68,7 +68,7 @@ class FederationHandler(BaseHandler):
|
|||
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()
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -409,7 +409,7 @@ class RoomListHandler(BaseHandler):
|
|||
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(
|
||||
|
|
|
@ -101,8 +101,8 @@ class HomeServer(object):
|
|||
DEPENDENCIES = [
|
||||
'http_client',
|
||||
'db_pool',
|
||||
'replication_client',
|
||||
'replication_server',
|
||||
'federation_client',
|
||||
'federation_server',
|
||||
'handlers',
|
||||
'v1auth',
|
||||
'auth',
|
||||
|
@ -199,10 +199,10 @@ class HomeServer(object):
|
|||
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):
|
||||
|
|
|
@ -47,7 +47,7 @@ class DirectoryTestCase(unittest.TestCase):
|
|||
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)
|
||||
|
|
|
@ -34,7 +34,7 @@ class E2eKeysHandlerTestCase(unittest.TestCase):
|
|||
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)
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ class ProfileTestCase(unittest.TestCase):
|
|||
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",
|
||||
|
|
|
@ -31,7 +31,7 @@ class BaseSlavedStoreTestCase(unittest.TestCase):
|
|||
self.hs = yield setup_test_homeserver(
|
||||
"blue",
|
||||
http_client=None,
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
ratelimiter=NonCallableMock(spec_set=[
|
||||
"send_message",
|
||||
]),
|
||||
|
|
|
@ -114,7 +114,7 @@ class EventStreamPermissionsTestCase(RestTestCase):
|
|||
|
||||
hs = yield setup_test_homeserver(
|
||||
http_client=None,
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
ratelimiter=NonCallableMock(spec_set=[
|
||||
"send_message",
|
||||
]),
|
||||
|
|
|
@ -45,7 +45,7 @@ class ProfileTestCase(unittest.TestCase):
|
|||
http_client=None,
|
||||
resource_for_client=self.mock_resource,
|
||||
federation=Mock(),
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
profile_handler=self.mock_handler
|
||||
)
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class RoomPermissionsTestCase(RestTestCase):
|
|||
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()
|
||||
|
@ -409,7 +409,7 @@ class RoomsMemberListTestCase(RestTestCase):
|
|||
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()
|
||||
|
@ -493,7 +493,7 @@ class RoomsCreateTestCase(RestTestCase):
|
|||
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()
|
||||
|
@ -582,7 +582,7 @@ class RoomTopicTestCase(RestTestCase):
|
|||
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()
|
||||
|
@ -697,7 +697,7 @@ class RoomMemberStateTestCase(RestTestCase):
|
|||
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()
|
||||
|
@ -829,7 +829,7 @@ class RoomMessagesTestCase(RestTestCase):
|
|||
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()
|
||||
|
@ -929,7 +929,7 @@ class RoomInitialSyncTestCase(RestTestCase):
|
|||
hs = yield setup_test_homeserver(
|
||||
"red",
|
||||
http_client=None,
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
ratelimiter=NonCallableMock(spec_set=[
|
||||
"send_message",
|
||||
]),
|
||||
|
@ -1003,7 +1003,7 @@ class RoomMessageListTestCase(RestTestCase):
|
|||
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()
|
||||
|
|
|
@ -47,7 +47,7 @@ class RoomTypingTestCase(RestTestCase):
|
|||
"red",
|
||||
clock=self.clock,
|
||||
http_client=None,
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
ratelimiter=NonCallableMock(spec_set=[
|
||||
"send_message",
|
||||
]),
|
||||
|
|
|
@ -42,7 +42,7 @@ class ApplicationServiceStoreTestCase(unittest.TestCase):
|
|||
hs = yield setup_test_homeserver(
|
||||
config=config,
|
||||
federation_sender=Mock(),
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
)
|
||||
|
||||
self.as_token = "token1"
|
||||
|
@ -119,7 +119,7 @@ class ApplicationServiceTransactionStoreTestCase(unittest.TestCase):
|
|||
hs = yield setup_test_homeserver(
|
||||
config=config,
|
||||
federation_sender=Mock(),
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
)
|
||||
self.db_pool = hs.get_db_pool()
|
||||
|
||||
|
@ -455,7 +455,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
|
|||
config=config,
|
||||
datastore=Mock(),
|
||||
federation_sender=Mock(),
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
)
|
||||
|
||||
ApplicationServiceStore(None, hs)
|
||||
|
@ -473,7 +473,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
|
|||
config=config,
|
||||
datastore=Mock(),
|
||||
federation_sender=Mock(),
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
)
|
||||
|
||||
with self.assertRaises(ConfigError) as cm:
|
||||
|
@ -497,7 +497,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
|
|||
config=config,
|
||||
datastore=Mock(),
|
||||
federation_sender=Mock(),
|
||||
replication_client=Mock(),
|
||||
federation_client=Mock(),
|
||||
)
|
||||
|
||||
with self.assertRaises(ConfigError) as cm:
|
||||
|
|
Loading…
Reference in a new issue