From a909fab7e3e3746d4372284e117b251b36553702 Mon Sep 17 00:00:00 2001 From: Fei Long Wang Date: Mon, 27 Jul 2015 12:17:19 +1200 Subject: [PATCH] Decouple the queue and subscription Now some parts of the subscription storage drivers is assuming the queue_controller is in the same storage. But unfortunately, it's not always true. This patch fixes it, but there is no new test case involved. Closes-Bug: #1471193 Change-Id: Ic81c928657addd4e0905c3af2b3c8321017559f5 --- zaqar/storage/mongodb/subscriptions.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/zaqar/storage/mongodb/subscriptions.py b/zaqar/storage/mongodb/subscriptions.py index 665a7fc3b..ce6837bc9 100644 --- a/zaqar/storage/mongodb/subscriptions.py +++ b/zaqar/storage/mongodb/subscriptions.py @@ -47,8 +47,7 @@ class SubscriptionController(base.Subscription): def __init__(self, *args, **kwargs): super(SubscriptionController, self).__init__(*args, **kwargs) self._collection = self.driver.subscriptions_database.subscriptions - queue_col = self.driver.control_driver.queues_database.queues - self._queue_collection = queue_col + self._queue_ctrl = self.driver.queue_controller self._collection.ensure_index(SUBSCRIPTIONS_INDEX, unique=True) @utils.raises_conn_error @@ -95,12 +94,9 @@ class SubscriptionController(base.Subscription): now = timeutils.utcnow_ts() ttl = int(ttl) expires = now + ttl - source_query = {'p_q': utils.scope_queue_name(source, project)} - target_source = self._queue_collection.find_one( - source_query, projection={'m': 1, '_id': 0}) - if target_source is None: - raise errors.QueueDoesNotExist(target_source, project) + if not self._queue_ctrl.exists(source, project): + raise errors.QueueDoesNotExist(source, project) try: subscription_id = self._collection.insert({'s': source, 'u': subscriber,