Open Eomm opened 1 year ago
You can already do this using wildcards. Set all workers to a wildcard by default, such as icecream.*
, then, you can replace the wildcard with a specific flavor
Sorry, I don't get it. Does the producer that send the message must know the consumer's queue in di case?
My target would be having a silly producer that does not know how many consumers the BE has
Queue patterns use the character to match 0 or more characters. For example, a job from queue status-report-12345 would be fetched with pattern status-report- or even stat*5.
For example, a producer would use the flavor as part of the queue name, such as icecream.vanilla
and icecream.chocolate
. A consumer using work('icecream.*')
would get both flavors, but another consumer using work('icecream.vanilla')
would not get chocolate.
The proposed solution assumes that I have control over the producer - it is not the case 😞
Would you mind to accept a PR with such a feature in case?
Yes, sounds good
This would be useful. I didn't see a test case for work('icecream.*.toppings.none')
sort of queue layouts.
Since wildcards have been dropped in v10, my original response is no longer valid. The most feasible option seems to be some sort of additional opt-in filter like originally proposed. The primary issue in using the data payload is fetch performance, since the data column is not indexed. I don't think indexing data is a good idea globally, since the payload could be large, and this would impact write performance as well.
However, this doesn't mean it's a deal-breaker. Now that queues are isolated via partitioning, this opens up the possibility of a diversity of indexing strategies since indexes in queue A wouldn't have to match indexes in queue B. One way to pull this off would be add a new option in createQueue()
.
In order to create a QOS system it would be great to support a
filter
option by thework()
method.This new parameter lets the user to write to a single queue/table and 2 different workers will be able to process the same queue at different pace:
icecream
icecream
with jobtaste: cioco
has a worker that process it withnewJobCheckInterval: 200
icecream
with jobtaste: bubble
has a worker that process it withnewJobCheckInterval: 2000
❗️ It is up to the user writing a filter that process all the jobs, otherwise the job with
taste: lemon
will be archived automatically.Example:
This should generate a query like this in the fetch function:
https://github.com/timgit/pg-boss/blob/523c36ba7bf285456c2358b710f13d8d77d34b3a/src/plans.js#L353
Note:
executeSql
function when the user customizes thedb
tooWhat do you think?