GithubHelp home page GithubHelp logo

Comments (2)

dlecocq avatar dlecocq commented on June 8, 2024

This should be possible by 1) ensuring that all the jobs in that queue are completed or canceled and then 2) calling queue.forget on the queue to remove it from the list of known queues. This will avoid all leakage.

from qless-core.

xmywang avatar xmywang commented on June 8, 2024

For our case, the deletion of queue is triggered by the user from our UI. We need cancel all jobs in the queue asap. So we write a small lua script:
In queue.lua, add this function:
{code}
-- List jobs and their depends ids
function QlessQueue.jobs(now, name, count)

local queue = Qless.queue(name)
-- These are the ids that we're going to return. We'll begin with any jobs
-- that have lost their locks
local jids = queue.work.peek(count)
table.extend(jids, queue.locks.peek(now, 0, count - #jids))
table.extend(jids, queue.scheduled.peek(now, 0, count - #jids))
table.extend(jids, queue.recurring.peek(now, 0, count - #jids))

local dependents = {}
for _, jid in ipairs(jids) do
dependents[jid] = redis.call(
'smembers', QlessJob.ns .. jid .. '-dependents') or {}
end
table.extend(jids, dependents)
return jids
end
{code}

In api.lua, we write this

{code}
QlessAPI['job.batch_cancel'] = function(now, queue, count)
local jids = QlessQueue.jobs(now, queue, count)
Qless.cancel(unpack(jids))
return #jids
end
{code}

In this way, our application can repeat calling job.batch_cancel to cancel all jobs in the queue. Then we can safely delete the queue.

Let's know if this is OK or not.

Thanks a lot!

Yan

from qless-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.