示例#1
0
    async def ack(self, xid: str, job: Job) -> List:
        """
        Acknowledge receipt of the ID:
            1. Remove it from the consumer's PEL.
            2. Delete the message from the stream.
            3. Set the status entry for the job to status.SUCCESS.
            4. Set expiry for the status entry.
        """
        job = job.replace(status=status.SUCCESS)

        tx = self.client.multi_exec()
        self._ack(tx, xid)
        self._status(tx, job, ttl=self.results_ttl)
        return await tx.execute()
示例#2
0
    async def ack_and_schedule(self, xid: str, job: Job) -> List:
        """
        Acknowledge receipt of the ID and schedule the job for reprocessing:
            1. Remove it from the consumer's PEL.
            2. Delete the message from the stream.
            3. Add the job to the schedule sorted set so that consumers can poll it.
            4. Set the status entry for the job to status.RETRY.
        """
        job = job.replace(status=status.RETRY)
        eta = now() + int(self.retry_backoff(job.tries))

        tx = self.client.multi_exec()
        self._ack(tx, xid)
        self._schedule(tx, job, eta)
        self._status(tx, job, ttl=None)
        return await tx.execute()
示例#3
0
    async def ack_and_store(self, xid: str, job: Job) -> List:
        """
        Acknowledge receipt of the ID and store the result:
            1. Remove it from the consumer's PEL.
            2. Delete the message from the stream.
            3. Delete any existing results (just in case it already exists).
            4. Store the result in a list so that clients can wait via BRPOPLPUSH.
            5. Set expiry for the result.
            6. Set the status entry for the job to status.SUCCESS.
            7. Set expiry for the status entry.
        """
        job = job.replace(status=status.SUCCESS)

        tx = self.client.multi_exec()
        self._ack(tx, xid)
        self._store(tx, job)
        self._status(tx, job, ttl=self.results_ttl)
        return await tx.execute()
示例#4
0
    async def ack_and_dead(self, xid: str, job: Job) -> List:
        """
        Acknowledge receipt of the ID and add the job to the dead-letter queue:
            1. Remove it from the consumer's PEL.
            2. Delete the message from the stream.
            3. Add the message to the DLQ.
            4. Delete any existing results (just in case it already exists).
            5. Store the result in a list so that clients can wait via BRPOPLPUSH.
            6. Set expiry for the result.
            7. Set the status entry for the job to status.DEAD.
        """
        job = job.replace(status=status.DEAD)

        tx = self.client.multi_exec()
        self._ack(tx, xid)
        self._dead(tx, job)
        self._store(tx, job)
        self._status(tx, job, ttl=None)
        return await tx.execute()