newfold-labs / wp-module-tasks

A task system for processing asynchronous tasks with wordpress, the tasks could be one-off long running tasks or periodic tasks.
2 stars 1 forks source link

Make cron schedule configurable #9

Open wpscholar opened 1 year ago

wpscholar commented 1 year ago

Having a 20-second cron schedule could overwhelm the site’s resources with overlapping cron tasks on a high-traffic site.

While I realize this 20-second cron is important when setting up a site to ensure plugins are properly installed during onboarding, I don't think we should retain this cron schedule past onboarding.

https://github.com/newfold-labs/wp-module-tasks/blob/a7d309cd8a693dd82e0c284834cc2b7ee3a8fb12/includes/Scheduler.php#L36-L59

The existing cleanup task should happen on the pre-existing 15-minute cron instead of adding a new 10-minute cron.

We should remove the 20-second cron and make it possible to configure custom cron schedules to handle different groups/types of tasks at different intervals.

wpscholar commented 1 year ago

Ultimately, I think we don't have enough classes to represent all the concepts and dependencies that we really want. I think we should probably have the following:

I'm looking at this as inspiration: https://github.com/deliciousbrains/wp-queue

I get that this is a bit of an involved rewrite if we do this, so if we need to circle back to this as a fast follow we can.