@@ -0,0 +1,2381 @@
+# -*- coding: utf-8 -*-%0A# Copyright 2016 matrix.org%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport collections%0A%0Afrom ._base import Config%0Afrom .server import read_gc_thresholds%0A%0A%0AWorker = collections.namedtuple(%22Worker%22, %5B%0A    %22app%22,%0A    %22listeners%22,%0A    %22pid_file%22,%0A    %22daemonize%22,%0A    %22log_file%22,%0A    %22log_config%22,%0A    %22event_cache_size%22,%0A    %22soft_file_limit%22,%0A    %22gc_thresholds%22,%0A    %22replication_url%22,%0A%5D)%0A%0A%0Adef clobber_with_worker_config(config, worker_config):%0A    %22%22%22Overrides some of the keys of the main config with worker-specific%0A    values.%22%22%22%0A    config.event_cache_size = worker_config.event_cache_size%0A    config.replication_url = worker_config.replication_url%0A%0A%0Adef read_worker_config(config):%0A    return Worker(%0A        app=config%5B%22app%22%5D,%0A        listeners=config.get(%22listeners%22, %5B%5D),%0A        pid_file=config.get(%22pid_file%22),%0A        daemonize=config%5B%22daemonize%22%5D,%0A        log_file=config.get(%22log_file%22),%0A        log_config=config.get(%22log_config%22),%0A        event_cache_size=Config.parse_size(config.get(%22event_cache_size%22, %2210K%22)),%0A        soft_file_limit=config.get(%22soft_file_limit%22),%0A        gc_thresholds=read_gc_thresholds(config.get(%22gc_thresholds%22)),%0A        replication_url=config.get(%22replication_url%22),%0A    )%0A%0A%0Aclass WorkerConfig(Config):%0A    %22%22%22The workers are processes run separately to the main synapse process.%0A    Each worker has a name that identifies it within the config file.%0A    They have their own pid_file and listener configuration. They use the%0A    replication_url to talk to the main synapse process. They have their%0A    own cache size tuning, gc threshold tuning and open file limits.%22%22%22%0A%0A    def read_config(self, config):%0A        workers = config.get(%22workers%22, %7B%7D)%0A%0A        self.workers = %7B%0A            worker_name: read_worker_config(worker_config)%0A            for worker_name, worker_config in workers.items()%0A        %7D%0A

Add worker config module