diff options
author | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-08-17 17:12:08 +0100 |
---|---|---|
committer | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-09-20 16:38:34 +0100 |
commit | 5e32e2b12a719f19be834da81567ebc328f29d54 (patch) | |
tree | df850d6419cb543f8fc1bfc8bb1f1537b057ab00 | |
parent | Added config section for state compressor (diff) | |
download | synapse-5e32e2b12a719f19be834da81567ebc328f29d54.tar.xz |
Added handling in config for when compressor not installed
-rw-r--r-- | synapse/app/_base.py | 8 | ||||
-rw-r--r-- | synapse/config/state_compressor.py | 24 | ||||
-rw-r--r-- | synapse/python_dependencies.py | 2 |
3 files changed, 24 insertions, 10 deletions
diff --git a/synapse/app/_base.py b/synapse/app/_base.py index cc2ddfe0c1..25bf996d38 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -454,16 +454,16 @@ def setup_state_compressor(hs): reactor=hs.get_reactor(), f=auto_compressor.compress_largest_rooms, db_url=db_url, - chunk_size=compressor_config.chunk_size, - default_levels=compressor_config.default_levels, - number_of_rooms=compressor_config.number_of_rooms, + chunk_size=compressor_config.compressor_chunk_size, + default_levels=compressor_config.compressor_default_levels, + number_of_rooms=compressor_config.compressor_number_of_rooms, ) # Call the compressor every `time_between_runs` milliseconds clock = hs.get_clock() clock.looping_call( run_state_compressor, - compressor_config.time_between_runs, + compressor_config.time_between_compressor_runs, ) diff --git a/synapse/config/state_compressor.py b/synapse/config/state_compressor.py index 0ab65f608d..d90474766f 100644 --- a/synapse/config/state_compressor.py +++ b/synapse/config/state_compressor.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from synapse.config._base import Config +from synapse.config._base import Config, ConfigError +from synapse.python_dependencies import DependencyException, check_requirements class StateCompressorConfig(Config): @@ -20,11 +21,22 @@ class StateCompressorConfig(Config): def read_config(self, config, **kwargs): compressor_config = config.get("state_compressor", {}) - self.enabled = compressor_config.get("enabled", False) - self.chunk_size = compressor_config.get("chunk_size", 500) - self.number_of_rooms = compressor_config.get("number_of_rooms", 5) - self.default_levels = compressor_config.get("default_levels", "100,50,25") - self.time_between_runs = self.parse_duration( + self.compressor_enabled = compressor_config.get("enabled", False) + + if not self.compressor_enabled: + return + + try: + check_requirements("auto_compressor") + except DependencyException as e: + raise ConfigError(e.message) + + self.compressor_chunk_size = compressor_config.get("chunk_size", 500) + self.compressor_number_of_rooms = compressor_config.get("number_of_rooms", 5) + self.compressor_default_levels = compressor_config.get( + "default_levels", "100,50,25" + ) + self.time_between_compressor_runs = self.parse_duration( compressor_config.get("time_between_runs", "1d") ) diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 154e5b7028..7c5570976e 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -114,6 +114,8 @@ CONDITIONAL_REQUIREMENTS = { "redis": ["txredisapi>=1.4.7", "hiredis"], # Required to use experimental `caches.track_memory_usage` config option. "cache_memory": ["pympler"], + # Needs to be manually installed to use + "auto_compressor": ["auto_compressor"], } ALL_OPTIONAL_REQUIREMENTS: Set[str] = set() |