breejs / bree

Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
https://jobscheduler.net
MIT License
2.96k stars 80 forks source link

[feat] Need to be able to remove job after # of runs #243

Closed dougbutner closed 5 months ago

dougbutner commented 5 months ago

Describe the feature

This repo would be a lot more useful if a certain action could run a specified number of times. Currently, there is the inability to have a job that is on two different schedules, so it becomes impossible to run just a certain number of times.

Checklist

titanism commented 5 months ago

You can write your own database/locking/lookup method, or use a counter (e.g. via Redis) to handle this.

dougbutner commented 5 months ago

So you suggest to keep the process running and failing a check every time? hmmm..

If you don't want to build the feature, or don't think it belongs in bree, it's okay to just say that.

dougbutner commented 5 months ago

The easy solution is to just allow a job to be in two schedules.

titanism commented 5 months ago

If you don't want to build the feature, or don't think it belongs in bree, it's okay to just say that.

This is open-source, you're not paying us anything right now, nor sponsoring our efforts. It's not that we don't want to build the feature, or think it belongs here – we simply don't care → we use this in production and implement our own locking mechanisms, counters, etc. This is not a bug, and the issue you described can be accomplished already. If you want to submit a working PR with tests added, that doesn't break existing behavior, go for it.

https://github.com/breejs/bree#:~:text=In%20doing%20so%2C%20you%20should%20manage%20boolean%20job%20states%20yourself%20using%20queries

dougbutner commented 5 months ago

Thanks for your time + tool. If I get around to it ill send a PR