diff --git a/zaqar/common/configs.py b/zaqar/common/configs.py index af49b0a5d..1ad269e57 100644 --- a/zaqar/common/configs.py +++ b/zaqar/common/configs.py @@ -58,6 +58,8 @@ _NOTIFICATION_OPTIONS = ( cfg.StrOpt('smtp_command', default='/usr/sbin/sendmail -t -oi', help=('The command of smtp to send email. The format is ' '"command_name arg1 arg2".')), + cfg.IntOpt('max_notifier_workers', default=10, + help='The max amount of the notification workers.') ) _NOTIFICATION_GROUP = 'notification' diff --git a/zaqar/notification/notifier.py b/zaqar/notification/notifier.py index 605d2fd8d..b5a1d66d9 100644 --- a/zaqar/notification/notifier.py +++ b/zaqar/notification/notifier.py @@ -32,8 +32,8 @@ class NotifierDriver(object): def __init__(self, *args, **kwargs): self.subscription_controller = kwargs.get('subscription_controller') - # TODO(flwang): Make the max_workers configurable - self.executor = futurist.ThreadPoolExecutor(max_workers=10) + max_workers = kwargs.get('max_notifier_workers', 10) + self.executor = futurist.ThreadPoolExecutor(max_workers=max_workers) def post(self, queue_name, messages, client_uuid, project=None): """Send messages to the subscribers.""" diff --git a/zaqar/storage/pipeline.py b/zaqar/storage/pipeline.py index d7df0fa42..15e3417d7 100644 --- a/zaqar/storage/pipeline.py +++ b/zaqar/storage/pipeline.py @@ -148,7 +148,9 @@ class DataDriver(base.DataDriverBase): stages = _get_builtin_entry_points('message', self._storage, self.control_driver) kwargs = {'subscription_controller': - self._storage.subscription_controller} + self._storage.subscription_controller, + 'max_notifier_workers': + self.conf.notification.max_notifier_workers} stages.extend(_get_storage_pipeline('message', self.conf, **kwargs)) stages.append(self._storage.message_controller) return common.Pipeline(stages) diff --git a/zaqar/tests/base.py b/zaqar/tests/base.py index 09d701a6a..436fc5447 100644 --- a/zaqar/tests/base.py +++ b/zaqar/tests/base.py @@ -56,6 +56,8 @@ class TestBase(testtools.TestCase): self.conf.register_opts(configs._GENERAL_OPTIONS) self.conf.register_opts(configs._DRIVER_OPTIONS, group=configs._DRIVER_GROUP) + self.conf.register_opts(configs._NOTIFICATION_OPTIONS, + group=configs._NOTIFICATION_GROUP) self.mongodb_url = os.environ.get('ZAQAR_TEST_MONGODB_URL', 'mongodb://127.0.0.1:27017')