Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to find a job in queue by it's ID #715

Open
ammirator-administrator opened this issue Apr 6, 2024 · 10 comments
Open

Possibility to find a job in queue by it's ID #715

ammirator-administrator opened this issue Apr 6, 2024 · 10 comments

Comments

@ammirator-administrator
Copy link

At the moment we have the list of all jobs in a queue separated in different tabs by it's status

But there is no possibility to find a job by it's ID and investigate it in case if needed
Imagine having a platform even if small but which handles let's say 1000 jobs a day
In that list it would be hard to go manually thru all and find the one you need

A small filter at the top would be super useful to find a job

@felixmosh
Copy link
Owner

Hi, would you like to prepare a PR for this feature? I'll more than happy to review it 😉

@OrionWambert
Copy link

Hi, would you like to prepare a PR for this feature? I'll more than happy to review it 😉

Hello, I'd like to contribute to this project. Is there any project documentation that could help me quickly understand the architecture and add functionalities?

@felixmosh
Copy link
Owner

Nope, just review the ui & api folders in packages

@suyash-thakur
Copy link

There is already a route GET /api/queues/:queueName/:jobId. I think just a UI element calling this endpoint will work. Let me know if I am wrong @felixmosh

@felixmosh
Copy link
Owner

Yeah, you are probably right... But it will return always one / zero result.

I prefer to implement a full search (once the underline lib will add it, vote for my request)

@ammirator-administrator
Copy link
Author

At least by ID would be good as Initial step
after this search may be extended and search by something else

I do not think that bullmq will add ever a fullsearch capability since it uses redis and to do something as full search with redis is hard

At the beginning it may be just by ID at least, since a lot of peoples just stores the IDs related to some job in a simple database so that they can cancel later or do some investigation if needed

@suyash-thakur
Copy link

suyash-thakur commented Jun 3, 2024

I agree. It's unlikely that bullmq will provide a fullsearch. To implement fullsearch from our side we will need to store the index in redis, if bullmq exports the redis client. Still it would not be best to utilise redis resources from the bull-board. Our best bet is to implement search by ID. If this is something we want to implement than I can work on a PR.

@ammirator-administrator
Copy link
Author

Thanks @suyash-thakur
That would be great if you can open such PR
I think this feature will help a lot of peoples to investigate their jobs

@bfbechlin
Copy link

I recently had to implement a search by job id prefix and I believe we could use the same approach for a simple job search engine. It's still not a full search but it adds a level of flexibility in the searches.
The code is pretty straightforward:

import { Queue, Job } from "bullmq";

export const getJobsByIdPrefix = async (queue: Queue, idPrefix: string, COUNT = 1000) => {
	const client = await queue.client;

	const BASE_MATCH = `bull:${queue.name}:`;
	const MATCH = `${BASE_MATCH}${idPrefix}*`;
	const [_, keys] = await client.scan(0, "MATCH", MATCH, "COUNT", COUNT);

	const promises = keys.map((key) => {
		const jobId = key.replace(BASE_MATCH, "");
		return Job.fromId(queue, jobId);
	});

	return Promise.all(promises);
}

@suyash-thakur @felixmosh What do you think about this approach?

@felixmosh
Copy link
Owner

You are using details that related to the storage (implementation details).
I don't want to know / use things that are not documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants