Open viebig opened 6 years ago
Priority support for delayed jobs have been added in 3.4.0: https://github.com/OptimalBits/bull/blob/master/CHANGELOG.md#v340
Thanks! Does it include lifo support?
no, not yet.
+1
@manast @alexkh13 I am looking for guidance on how to PR delayed lifo jobs. I guess that I need to follow this commit of prioritized delayed, right? https://github.com/OptimalBits/bull/commit/e3c1775aa6b1541b623a58f411f62e6d6f2a71a2 but do I need to change any thing here: https://github.com/OptimalBits/bull/blob/f1d8cc3b082bfaf0b715438b9a98c75ee9e826a3/lib/job.js#L242 or is it just for retrying jobs, and it is unrelated.
@nitzanav no, i don't see how this line is related.
i think you should focus on this block https://github.com/OptimalBits/bull/blob/f1d8cc3b082bfaf0b715438b9a98c75ee9e826a3/lib/commands/updateDelaySet-4.lua#L39
based on whether or not the job enables lifo you should LINSERT to right place
currently, it inserts it to the left of the "already inserted" priority jobs for example, if you insert a priority=2 job to the wait queue ZCOUNT will count all 1s and 2s which is 4 it will then take the length of the list and subtract 4 (6-4=2)
LEFT ||| 3 | 3 | **2** | 2 | 1 | 1 ||| RIGHT
^
the ^ indicates where it will put it (to the left of index=2)
so what you basically want to do when lifo is enabled is to count (prioriy-1) and insert it to the left. so in the above example it would count only the 1s (6-2=4)
LEFT ||| 3 | 3 | 2 | 2 | **1** | 1 ||| RIGHT
^
if it didn't find any (priority-1) the RPUSH is still ok.
please, double check what i just said.
@alexkh13
Thanks a lot for the thorough input
I see now that there are two kind of tasks:
It seems that you describe task 1
I am intetested in task 2.
maybe best to create two seperate issues and close this one, not sure what is the best.
Task 2 (delayed 2) is just to add condition that will do RPUSH in case of lifo around this line: https://github.com/OptimalBits/bull/blob/f1d8cc3b082bfaf0b715438b9a98c75ee9e826a3/lib/commands/updateDelaySet-4.lua#L39
then I need to follow you "prioritized delayed" commit to see how to propogate the parater to the lua script.
right?
BTW, if anyone have a remote developer that can make several PRs for me and do some Bull developmemt it will be nice. please contact me nitzan.aviram@ongage.com
I'm not sure I understand what are the 2 kinds you described. But, yes, you'll have to propagate the lifo param like "prioritized delayed" commit did with the priority param.
Description
When I use delayed jobs, lifo and priority options don't work.
Test code to reproduce
Code without delay
Output without delay
Code with delay
Output with delay
Bull version
^3.3.10
Additional information
My workaround was using setTimeout to delay with lifo