Commit Graph

9 Commits

Author SHA1 Message Date
Naz
f1ab1597e8 Changed scheduled jobs not run immediately after initialization
refs https://github.com/breejs/bree/issues/50
2020-11-23 14:24:24 +13:00
Naz
4b18cbcbdb Added support for worker threads in scheduled jobs
no issue

- When jobs are performing CPU intensive tasks they block main process'
event loop. They also can cause memory leaks or unexpected crashes
effectively crashing the parent proccess. To address these issues jobs need to be performed off of main
process. Worker Threads (https://nodejs.org/dist/latest-v12.x/docs/api/worker_threads.html)
are the best candidate for such work.
- These changes introduce an integration on top of bree
(https://github.com/breejs/bree/) which allows to run recurring
jobs in worker thereads. It falls back to child process execution for
Node v10 running without `--experimental-worker` flag.
- bree was chosen not only because it gives a polyfill for older Node
versions. It has support for some of the future use-cases Ghost is looking to
implement, like scheduled jobs.
- This changeset also includes a complete example of job running on an
interval with a possibility for graceful shutdown
2020-11-19 17:59:36 +13:00
Naz
e6e7dc93dd Added test coverage for graceful job queue shutdown 2020-11-17 18:14:37 +13:00
Naz
7925f12fcc Fixed lint for arrow function use in beforeEach block 2020-11-10 17:15:08 +13:00
Naz
85b51524c9 Added loggign and more graceful error handling
no issue

- This is a quick implementation change to prevent from queue stalling and never becoming idle in case there's an error thrown from within the job function/module
- More robust error handling should be designed soon!
2020-11-10 17:11:24 +13:00
Naz
7dac72d6bf Added test coverage for basic job registration 2020-11-10 16:35:04 +13:00
Naz
ae4f35ddd8 Changed scheduleJob method signature to take when parameter first
no issue

- Accepting the schedule or a data when scheduled job should be run would follow a signature used in other established frameworks: (1) https://github.com/mperham/sidekiq/wiki/Ent-Periodic-Jobs#definition
- Another reason to put scheduling parameter first is this would allow leaving an optional "data" parameter as last
2020-11-10 13:15:10 +13:00
Naz
1b1794063f Added experimental job scheduling feature
no issue

- This method should be used with caution and should serve as a playground for upcoming new feature of scheduled jobs support
2020-11-05 17:36:29 +13:00
Naz
8c24e093d3 Added basic test checking module API 2020-11-05 16:39:51 +13:00