mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 09:44:49 -04:00
Performance improvements and refactor of Ratelimiter (#7595)
While working on https://github.com/matrix-org/synapse/issues/5665 I found myself digging into the `Ratelimiter` class and seeing that it was both: * Rather undocumented, and * causing a *lot* of config checks This PR attempts to refactor and comment the `Ratelimiter` class, as well as encourage config file accesses to only be done at instantiation. Best to be reviewed commit-by-commit.
This commit is contained in:
parent
c389bfb6ea
commit
f4e6495b5d
19 changed files with 325 additions and 233 deletions
|
@ -242,9 +242,12 @@ class HomeServer(object):
|
|||
|
||||
self.clock = Clock(reactor)
|
||||
self.distributor = Distributor()
|
||||
self.ratelimiter = Ratelimiter()
|
||||
self.admin_redaction_ratelimiter = Ratelimiter()
|
||||
self.registration_ratelimiter = Ratelimiter()
|
||||
|
||||
self.registration_ratelimiter = Ratelimiter(
|
||||
clock=self.clock,
|
||||
rate_hz=config.rc_registration.per_second,
|
||||
burst_count=config.rc_registration.burst_count,
|
||||
)
|
||||
|
||||
self.datastores = None
|
||||
|
||||
|
@ -314,15 +317,9 @@ class HomeServer(object):
|
|||
def get_distributor(self):
|
||||
return self.distributor
|
||||
|
||||
def get_ratelimiter(self):
|
||||
return self.ratelimiter
|
||||
|
||||
def get_registration_ratelimiter(self):
|
||||
def get_registration_ratelimiter(self) -> Ratelimiter:
|
||||
return self.registration_ratelimiter
|
||||
|
||||
def get_admin_redaction_ratelimiter(self):
|
||||
return self.admin_redaction_ratelimiter
|
||||
|
||||
def build_federation_client(self):
|
||||
return FederationClient(self)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue