mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:16:09 -04:00
Use direct references for some configuration variables (#10798)
Instead of proxying through the magic getter of the RootConfig object. This should be more performant (and is more explicit).
This commit is contained in:
parent
9f111075e8
commit
01c88a09cd
66 changed files with 152 additions and 133 deletions
|
@ -271,7 +271,7 @@ class DataStore(
|
|||
|
||||
def get_users_paginate_txn(txn):
|
||||
filters = []
|
||||
args = [self.hs.config.server_name]
|
||||
args = [self.hs.config.server.server_name]
|
||||
|
||||
# Set ordering
|
||||
order_by_column = UserSortOrder(order_by).value
|
||||
|
@ -356,13 +356,13 @@ def check_database_before_upgrade(cur, database_engine, config: HomeServerConfig
|
|||
return
|
||||
|
||||
user_domain = get_domain_from_id(rows[0][0])
|
||||
if user_domain == config.server_name:
|
||||
if user_domain == config.server.server_name:
|
||||
return
|
||||
|
||||
raise Exception(
|
||||
"Found users in database not native to %s!\n"
|
||||
"You cannot change a synapse server_name after it's been configured"
|
||||
% (config.server_name,)
|
||||
% (config.server.server_name,)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class CensorEventsStore(EventsWorkerStore, CacheInvalidationWorkerStore, SQLBase
|
|||
super().__init__(database, db_conn, hs)
|
||||
|
||||
if (
|
||||
hs.config.run_background_tasks
|
||||
hs.config.worker.run_background_tasks
|
||||
and self.hs.config.redaction_retention_period is not None
|
||||
):
|
||||
hs.get_clock().looping_call(self._censor_redactions, 5 * 60 * 1000)
|
||||
|
|
|
@ -355,7 +355,7 @@ class ClientIpWorkerStore(ClientIpBackgroundUpdateStore):
|
|||
|
||||
self.user_ips_max_age = hs.config.user_ips_max_age
|
||||
|
||||
if hs.config.run_background_tasks and self.user_ips_max_age:
|
||||
if hs.config.worker.run_background_tasks and self.user_ips_max_age:
|
||||
self._clock.looping_call(self._prune_old_user_ips, 5 * 1000)
|
||||
|
||||
@wrap_as_background_process("prune_old_user_ips")
|
||||
|
|
|
@ -51,7 +51,7 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
def __init__(self, database: DatabasePool, db_conn, hs):
|
||||
super().__init__(database, db_conn, hs)
|
||||
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._clock.looping_call(
|
||||
self._prune_old_outbound_device_pokes, 60 * 60 * 1000
|
||||
)
|
||||
|
|
|
@ -62,7 +62,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
|
|||
def __init__(self, database: DatabasePool, db_conn, hs):
|
||||
super().__init__(database, db_conn, hs)
|
||||
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
hs.get_clock().looping_call(
|
||||
self._delete_old_forward_extrem_cache, 60 * 60 * 1000
|
||||
)
|
||||
|
|
|
@ -82,7 +82,7 @@ class EventPushActionsWorkerStore(SQLBaseStore):
|
|||
self._rotate_delay = 3
|
||||
self._rotate_count = 10000
|
||||
self._doing_notif_rotation = False
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._rotate_notif_loop = self._clock.looping_call(
|
||||
self._rotate_notifs, 30 * 60 * 1000
|
||||
)
|
||||
|
|
|
@ -158,7 +158,7 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
db_conn, "events", "stream_ordering", step=-1
|
||||
)
|
||||
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
# We periodically clean out old transaction ID mappings
|
||||
self._clock.looping_call(
|
||||
self._cleanup_old_transaction_ids,
|
||||
|
|
|
@ -56,7 +56,7 @@ class ServerMetricsStore(EventPushActionsWorkerStore, SQLBaseStore):
|
|||
super().__init__(database, db_conn, hs)
|
||||
|
||||
# Read the extrems every 60 minutes
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._clock.looping_call(self._read_forward_extremities, 60 * 60 * 1000)
|
||||
|
||||
# Used in _generate_user_daily_visits to keep track of progress
|
||||
|
|
|
@ -132,14 +132,14 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
|
|||
hs.config.account_validity.account_validity_startup_job_max_delta
|
||||
)
|
||||
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._clock.call_later(
|
||||
0.0,
|
||||
self._set_expiration_date_when_missing,
|
||||
)
|
||||
|
||||
# Create a background job for culling expired 3PID validity tokens
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._clock.looping_call(
|
||||
self.cull_expired_threepid_validation_tokens, THIRTY_MINUTES_IN_MS
|
||||
)
|
||||
|
|
|
@ -815,7 +815,7 @@ class RoomWorkerStore(SQLBaseStore):
|
|||
If it is `None` media will be removed from quarantine
|
||||
"""
|
||||
logger.info("Quarantining media: %s/%s", server_name, media_id)
|
||||
is_local = server_name == self.config.server_name
|
||||
is_local = server_name == self.config.server.server_name
|
||||
|
||||
def _quarantine_media_by_id_txn(txn):
|
||||
local_mxcs = [media_id] if is_local else []
|
||||
|
|
|
@ -81,7 +81,7 @@ class RoomMemberWorkerStore(EventsWorkerStore):
|
|||
txn.close()
|
||||
|
||||
if (
|
||||
self.hs.config.run_background_tasks
|
||||
self.hs.config.worker.run_background_tasks
|
||||
and self.hs.config.metrics_flags.known_servers
|
||||
):
|
||||
self._known_servers_count = 1
|
||||
|
|
|
@ -48,7 +48,7 @@ class SessionStore(SQLBaseStore):
|
|||
super().__init__(database, db_conn, hs)
|
||||
|
||||
# Create a background job for culling expired sessions.
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._clock.looping_call(self._delete_expired_sessions, 30 * 60 * 1000)
|
||||
|
||||
async def create_session(
|
||||
|
|
|
@ -672,7 +672,7 @@ class StatsStore(StateDeltasStore):
|
|||
|
||||
def get_users_media_usage_paginate_txn(txn):
|
||||
filters = []
|
||||
args = [self.hs.config.server_name]
|
||||
args = [self.hs.config.server.server_name]
|
||||
|
||||
if search_term:
|
||||
filters.append("(lmr.user_id LIKE ? OR displayname LIKE ?)")
|
||||
|
|
|
@ -60,7 +60,7 @@ class TransactionWorkerStore(CacheInvalidationWorkerStore):
|
|||
def __init__(self, database: DatabasePool, db_conn, hs):
|
||||
super().__init__(database, db_conn, hs)
|
||||
|
||||
if hs.config.run_background_tasks:
|
||||
if hs.config.worker.run_background_tasks:
|
||||
self._clock.looping_call(self._cleanup_transactions, 30 * 60 * 1000)
|
||||
|
||||
@wrap_as_background_process("cleanup_transactions")
|
||||
|
|
|
@ -510,7 +510,7 @@ class UserDirectoryStore(UserDirectoryBackgroundUpdateStore):
|
|||
self._prefer_local_users_in_search = (
|
||||
hs.config.user_directory_search_prefer_local_users
|
||||
)
|
||||
self._server_name = hs.config.server_name
|
||||
self._server_name = hs.config.server.server_name
|
||||
|
||||
async def remove_from_user_dir(self, user_id: str) -> None:
|
||||
def _remove_from_user_dir_txn(txn):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue