Exemplo n.º 1
0
        def denormalizer(msg):
            oid = msg['_id']
            age = now - utils.oid_utc(oid)

            return {
                'id': str(oid),
                'age': age.seconds,
                'ttl': msg['t'],
                'body': msg['b'],
            }
Exemplo n.º 2
0
def _basic_message(msg, now):
    oid = msg['_id']
    age = timeutils.delta_seconds(utils.oid_utc(oid), now)

    return {
        'id': str(oid),
        'age': int(age),
        'ttl': msg['t'],
        'body': msg['b'],
    }
Exemplo n.º 3
0
def _basic_message(msg, now):
    oid = msg['_id']
    age = timeutils.delta_seconds(utils.oid_utc(oid), now)

    return {
        'id': str(oid),
        'age': int(age),
        'ttl': msg['t'],
        'body': msg['b'],
    }
Exemplo n.º 4
0
    def get(self, queue, claim_id, project=None):
        msg_ctrl = self.driver.message_controller

        # Check whether the queue exists or not
        qid = self._get_queue_id(queue, project)

        # Base query, always check expire time
        now = timeutils.utcnow()

        try:
            cid = utils.to_oid(claim_id)
        except ValueError:
            raise exceptions.ClaimDoesNotExist()

        age = now - utils.oid_utc(cid)

        def messages(msg_iter):
            msg = next(msg_iter)
            yield msg.pop('claim')
            yield msg

            # Smoke it!
            for msg in msg_iter:
                del msg['claim']
                yield msg

        try:
            # Lets get claim's data
            # from the first message
            # in the iterator
            messages = messages(msg_ctrl.claimed(qid, cid, now))
            claim = next(messages)
            claim = {
                'age': age.seconds,
                'ttl': claim.pop('t'),
                'id': str(claim['id']),
            }
        except StopIteration:
            raise exceptions.ClaimDoesNotExist(cid, queue, project)

        return (claim, messages)
Exemplo n.º 5
0
def _basic_message(msg, now):
    oid = msg["_id"]
    age = timeutils.delta_seconds(utils.oid_utc(oid), now)

    return {"id": str(oid), "age": int(age), "ttl": msg["t"], "body": msg["b"]}