コード例 #1
0
    def delete(self, name, project=None):
        if not self.exists(name, project):
            raise errors.QueueDoesNotExist(name, project)

        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)
        # Delete ensures the removal of the queue from the
        # project bucket.
        project_bkt.delete(q_name)
コード例 #2
0
    def get_metadata(self, name, project=None):
        if not self.exists(name, project):
            raise errors.QueueDoesNotExist(name, project)

        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)

        q_info = project_bkt.get(q_name).data
        return q_info['m']
コード例 #3
0
    def get_metadata(self, name, project=None):
        if not self.exists(name, project):
            raise errors.QueueDoesNotExist(name, project)

        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)

        q_info = project_bkt.get(q_name).data
        return q_info['m']
コード例 #4
0
    def delete(self, name, project=None):
        if not self.exists(name, project):
            raise errors.QueueDoesNotExist(name, project)

        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)
        # Delete ensures the removal of the queue from the
        # project bucket.
        project_bkt.delete(q_name)
コード例 #5
0
    def create(self, name, project=None):
        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)

        if self.exists(name, project):
            return False

        q_info = {'c': 1, 'm': {}, 't': timeutils.utcnow_ts()}
        # Riak python client supports automatic
        # serialization of py dicts <-> JSON.
        q_obj = project_bkt.new(q_name, q_info)
        q_obj.add_index(QUEUE_MODTIME_INDEX, q_info['t'])
        q_obj.store()
        return True
コード例 #6
0
    def set_metadata(self, name, metadata, project=None):
        if not self.exists(name, project):
            raise errors.QueueDoesNotExist(name, project)

        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)

        q_info = project_bkt.get(q_name)
        q_data = q_info.data
        # Set the new metadata.
        q_data['m'] = metadata
        q_data['t'] = timeutils.utcnow_ts()
        # Store the back into the bucket.
        # Note(prashanthr_): Check if re-indexing is needed.
        q_info.add_index(QUEUE_MODTIME_INDEX, q_data['t'])
        q_info.store()
コード例 #7
0
    def set_metadata(self, name, metadata, project=None):
        if not self.exists(name, project):
            raise errors.QueueDoesNotExist(name, project)

        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)

        q_info = project_bkt.get(q_name)
        q_data = q_info.data
        # Set the new metadata.
        q_data['m'] = metadata
        q_data['t'] = timeutils.utcnow_ts()
        # Store the back into the bucket.
        # Note(prashanthr_): Check if re-indexing is needed.
        q_info.add_index(QUEUE_MODTIME_INDEX, q_data['t'])
        q_info.store()
コード例 #8
0
    def create(self, name, project=None):
        q_name = utils.scope_queue_name(name, project)
        project_bkt = self._get_project_bkt(project)

        if self.exists(name, project):
            return False

        q_info = {
            'c': 1,
            'm': {},
            't': timeutils.utcnow_ts()
        }
        # Riak python client supports automatic
        # serialization of py dicts <-> JSON.
        q_obj = project_bkt.new(q_name, q_info)
        q_obj.add_index(QUEUE_MODTIME_INDEX, q_info['t'])
        q_obj.store()
        return True
コード例 #9
0
 def exists(self, name, project=None):
     # The exists attribute of the Riak Object
     # confirms the existance of the queue.
     q_name = utils.scope_queue_name(name, project)
     project_bkt = self._get_project_bkt(project)
     return project_bkt.get(q_name).exists
コード例 #10
0
 def exists(self, name, project=None):
     # The exists attribute of the Riak Object
     # confirms the existance of the queue.
     q_name = utils.scope_queue_name(name, project)
     project_bkt = self._get_project_bkt(project)
     return project_bkt.get(q_name).exists