-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Feature Request: Extract data from job to use as job Title #349
Comments
Did you tried |
Perhaps my wording wasn't clear or I am misunderstanding the use of prefix. I need the job titles to be unique per job. I was under the impression, the prefix is just static and used for all jobs. Am I incorrect? |
Yes, you are correct. Can you explain what do you want? |
The easiest explanation would be something along the lines of this: await bullQueue.add(jobItem, { jobTitle: "Downloading 123" })
await bullQueue.add(jobItem, { jobTitle: "Unzipping 123" })
await bullQueue.add(jobItem, { jobTitle: "Installing 123" }) I understand that example may still be confusing due to the above example should use different queues - BUT it's just an example. I have a case where all jobs are the same type, but I want the titles to be unique at the time of adding them. |
@bugs181 , I think that you've got confused, If you are using if you are using |
Unfortunately, I think there's a language barrier here. I'm fully aware of what bull-dashboard is. Displaying job data is exactly the purpose of the bull-board. Named jobs do not fulfill this purpose. I believe that a more generic approach, allowing users to dive into the job data to retrieve specific data for their job title on bull dashboard is important. Pictures are worth a thousand words, so let me show you what I'm trying to accomplish instead. The reason I was using The other reason I used This also brings into focus the fact that if we don't use named jobs we get TL;DRFor clarification: The whole point of this feature request is to ask for the ability to extract data from the |
Ok, I think that i get it, what is your use case for this feature? |
Many more use cases than the one example above. Running a custom By using an A proposal example could be useful here: const queueOptions = {
getTitle: function(jobProps) {
return jobProps.data.title ? jobProps.data.title : jobProps.name
}
}
createBullBoard({
queues: [new BullAdapter(bullQueue, queueOptions)],
serverAdapter,
}) Example titles could be different job data exposed for staged environments, job paths that are taken to arrive at the queue, etc. Basically, any kind of data that could be useful at a glance. One such use-case I have is exposing Drone CI repo names. This would make my titles look like these:
Current solution:Currently, I'm overriding name: jobProps.data.title ? jobProps.data.title : jobProps.name, This would essentially get turned into something along the lines of this (with my above proposal): const queueOptions = {
getTitle: function(jobProps) {
const repo = jobProps.data
return repo.action && repo.name ? `${repo.action} repo ${repo.name}` : jobProps.name
}
}
createBullBoard({
queues: [new BullAdapter(bullQueue, queueOptions)],
serverAdapter,
})
// Then in my bull I use this:
const jobItem = {
task: 'clone',
action: 'Cloning',
name: 'bugs181/bull-board-example'
}
await bullQueue.add(jobItem) This example would output |
We do have a built in formatters pattern that applies only on If I will add a support for formatting the So, you will able to pass a formatter for the // server.js
const Queue = require('bull')
const QueueMQ = require('bullmq')
const { setQueues, BullMQAdapter, BullAdapter } = require('bull-board')
const someQueue = new Queue()
const someOtherQueue = new Queue()
const queueMQ = new QueueMQ()
const someQueueAdapter = new BullAdapter(someQueue);
// This is the proposed api
someQueueAdapter.setFormatter('name', function(jobProps) {
const repo = jobProps.data
return repo.action && repo.name ? `${repo.action} repo ${repo.name}` : jobProps.name
}); // this will apply name formatter
setQueues([
someQueueAdapter,
new BullAdapter(someOtherQueue),
new BullMQAdapter(queueMQ),
]); WDYT? |
Your proposed solution could work. Not sure what other implications there are of formatting the data, though. It might be tricky to evaluate where the data came from if it modifies the |
I don't agree, we are already have the concept of formatting other fields on the |
I think I see one more issue with Edit: actually, I was misreading the code. It appears you are just setting the function to |
If it solves your issue, I will make a PR, if you want to help, It will be faster, but I do want to continue the same existing pattern. |
That's acceptable. Code style aside, to each their own. No complaints here either way as long as we can accomplish the same task. I had a look at |
No problem, I will make a PR. :] |
Doh! Silly me. I was over-complicating it. This should do the trick: Unless you see something I missed, I'll revert the PR and apply this patch. |
Yeap :] |
Thanks so much for your help! This looks great! |
Thank you for you patience |
Released in |
A few versions back, I was "abusing" the named job parameter to have better titles on the dashboard. After upgrading to the latest; when named jobs are used we get the lovely "Missing process handler" error. I'll try working on a PR to add support to make this a little more generic which can be useful for other cases.
Original named jobs method that I was abusing to accomplish this goal:
Proposal 1:
Append
title
parameter toQueueOptions
, which is just a generic JSON extractor.Example:
Proposal 2:
Append
jobTitle?
parameter toJobOptions
, which is just a generic JSON extractor.Example:
Expected Output:
Expected title output would be something along the lines of:
`${jobName} - ${jobTitle}`
Bonus options:
replace?: boolean | undefined;
- Replace entire job title for the expected output section, instead of appendingjobTitle
tojobName
.The text was updated successfully, but these errors were encountered: