rq / rq

Simple job queues for Python
https://python-rq.org
Other
9.84k stars 1.41k forks source link

Ability to see all running jobs for similar method #1117

Open ibrahim12 opened 5 years ago

ibrahim12 commented 5 years ago

Currently there is no way to search or query all jobs for a similar method other then fetch all jobs and map in python.

What about having that functionality ? May be storing job ids by method.

Code example

def add(a, b):
   return a+ b

def minus(a, b):
  return a + b

> queue.get_jobs_for(add)

add(1, 2)
add(2, 3)
add(4, 5)

> queue.get_jobs_for(minus)

minus(2, 3)
minus(4, 5)
minus(6, 7)
selwin commented 5 years ago

No, at the moment we don't keep track of job types. This would be something that I'm looking to add in the future.

ibrahim12 commented 5 years ago

I would be happy to discuss about the changes required and work on it if you are interested

selwin commented 5 years ago

My initial thinking is that we can have something like a JobTypeRegistry which contains job IDs and their expiration time.

Similar to StartedJobRegistry and other registry types, we'll have one Registry for each type of job and queue combination. So if you have jobs foo and bar, there will be two registries, each containing job IDs and their expiration times (if any).

ibrahim12 commented 5 years ago

So if we have n job types, then we would require n (registry + queue combination).

Do you think this will scale with larger job types ?