示例#1
0
    def list(self, queue, project=None, marker=None, limit=10):
        client = self._client
        subset_key = utils.scope_subscription_ids_set(queue, project,
                                                      SUBSCRIPTION_IDS_SUFFIX)
        rank = client.zrank(subset_key, marker)
        start = rank + 1 if rank is not None else 0

        cursor = (q
                  for q in client.zrange(subset_key, start, start + limit - 1))
        marker_next = {}

        def denormalizer(record, sid):
            now = timeutils.utcnow_ts()
            ttl = int(record[2])
            expires = int(record[3])
            created = expires - ttl
            ret = {
                'id': sid,
                'source': record[0],
                'subscriber': record[1],
                'ttl': ttl,
                'age': now - created,
                'options': self._unpacker(record[4]),
            }
            marker_next['next'] = sid

            return ret

        yield utils.SubscriptionListCursor(self._client, cursor, denormalizer)
        yield marker_next and marker_next['next']
示例#2
0
    def list(self, queue, project=None, marker=None, limit=10):
        client = self._client
        subset_key = utils.scope_subscription_ids_set(queue, project,
                                                      SUBSCRIPTION_IDS_SUFFIX)
        marker = utils.scope_queue_name(marker, project)
        rank = client.zrank(subset_key, marker)
        start = rank + 1 if rank else 0

        cursor = (q
                  for q in client.zrange(subset_key, start, start + limit - 1))
        marker_next = {}

        def denormalizer(record, sid):
            ret = {
                'id': sid,
                'source': record[0],
                'subscriber': record[1],
                'ttl': record[2],
                'options': json.loads(record[3]),
            }
            marker_next['next'] = sid

            return ret

        yield utils.SubscriptionListCursor(self._client, cursor, denormalizer)
        yield marker_next and marker_next['next']