"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zaqar/storage/redis/subscriptions.py" between
zaqar-9.0.0.tar.gz and zaqar-10.0.0.tar.gz

About: OpenStack Zaqar is a multi-tenant cloud messaging and notification service for web and mobile developers.
The "Ussuri" series (latest release).

subscriptions.py  (zaqar-9.0.0):subscriptions.py  (zaqar-10.0.0)
skipping to change at line 80 skipping to change at line 80
def denormalizer(record, sid): def denormalizer(record, sid):
now = timeutils.utcnow_ts() now = timeutils.utcnow_ts()
ttl = int(record[2]) ttl = int(record[2])
expires = int(record[3]) expires = int(record[3])
created = expires - ttl created = expires - ttl
is_confirmed = 1 is_confirmed = 1
if len(record) == 6: if len(record) == 6:
is_confirmed = record[5] is_confirmed = record[5]
ret = { ret = {
'id': sid, 'id': sid,
'source': record[0], 'source': record[0].decode(),
'subscriber': record[1], 'subscriber': record[1].decode(),
'ttl': ttl, 'ttl': ttl,
'age': now - created, 'age': now - created,
'options': self._unpacker(record[4]), 'options': self._unpacker(record[4]),
'confirmed': is_confirmed, 'confirmed': is_confirmed.decode(),
} }
marker_next['next'] = sid marker_next['next'] = sid
return ret return ret
yield utils.SubscriptionListCursor(self._client, cursor, denormalizer) yield utils.SubscriptionListCursor(self._client, cursor, denormalizer)
yield marker_next and marker_next['next'] yield marker_next and marker_next['next']
@utils.raises_conn_error @utils.raises_conn_error
@utils.retries_on_connection_error @utils.retries_on_connection_error
skipping to change at line 169 skipping to change at line 169
sub_ids = (q for q in self._client.zrange(subset_key, 0, -1)) sub_ids = (q for q in self._client.zrange(subset_key, 0, -1))
for s_id in sub_ids: for s_id in sub_ids:
subscription = self._client.hmget(s_id, subscription = self._client.hmget(s_id,
['s', 'u', 't', 'o', 'c']) ['s', 'u', 't', 'o', 'c'])
if subscription == [None, None, None, None, None]: if subscription == [None, None, None, None, None]:
# NOTE(flwang): Under this check, that means the # NOTE(flwang): Under this check, that means the
# subscription has been expired. So redis can't get # subscription has been expired. So redis can't get
# the subscription but the id is still there. So let's # the subscription but the id is still there. So let's
# delete the id for clean up. # delete the id for clean up.
self._client.zrem(subset_key, s_id) self._client.zrem(subset_key, s_id)
if subscription[1] == subscriber: if subscription[1].decode() == subscriber:
return True return True
return False return False
except redis.exceptions.ResponseError: except redis.exceptions.ResponseError:
return True return True
@utils.raises_conn_error @utils.raises_conn_error
@utils.retries_on_connection_error @utils.retries_on_connection_error
def exists(self, queue, subscription_id, project=None): def exists(self, queue, subscription_id, project=None):
subset_key = utils.scope_subscription_ids_set(queue, project, subset_key = utils.scope_subscription_ids_set(queue, project,
SUBSCRIPTION_IDS_SUFFIX) SUBSCRIPTION_IDS_SUFFIX)
skipping to change at line 253 skipping to change at line 253
@utils.raises_conn_error @utils.raises_conn_error
@utils.retries_on_connection_error @utils.retries_on_connection_error
def get_with_subscriber(self, queue, subscriber, project=None): def get_with_subscriber(self, queue, subscriber, project=None):
subset_key = utils.scope_subscription_ids_set(queue, subset_key = utils.scope_subscription_ids_set(queue,
project, project,
SUBSCRIPTION_IDS_SUFFIX) SUBSCRIPTION_IDS_SUFFIX)
sub_ids = (q for q in self._client.zrange(subset_key, 0, -1)) sub_ids = (q for q in self._client.zrange(subset_key, 0, -1))
for s_id in sub_ids: for s_id in sub_ids:
subscription = self._client.hmget(s_id, subscription = self._client.hmget(s_id,
['s', 'u', 't', 'o', 'c']) ['s', 'u', 't', 'o', 'c'])
if subscription[1] == subscriber: if subscription[1].decode() == subscriber:
subscription = SubscriptionEnvelope.from_redis(s_id, subscription = SubscriptionEnvelope.from_redis(s_id,
self._client) self._client)
now = timeutils.utcnow_ts() now = timeutils.utcnow_ts()
return subscription.to_basic(now) return subscription.to_basic(now)
@utils.raises_conn_error @utils.raises_conn_error
@utils.retries_on_connection_error @utils.retries_on_connection_error
def confirm(self, queue, subscription_id, project=None, confirmed=True): def confirm(self, queue, subscription_id, project=None, confirmed=True):
# Let's get our subscription by ID. If it does not exist, # Let's get our subscription by ID. If it does not exist,
# SubscriptionDoesNotExist error will be raised internally. # SubscriptionDoesNotExist error will be raised internally.
 End of changes. 4 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)