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)
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']
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
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()
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
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