-
Notifications
You must be signed in to change notification settings - Fork 24
Description
We should have a way of checking whether each feed has a retrieval cron job set. If the cron event doesn't exist, we should schedule it.
We already do something similar on 'save_post' with PressForward\Core\Schema\Feeds\set_up_feed_retrieval_cron_job(). We could use this same callback to do the check-and-set.
The architectural question is: how best to trigger this check? It needs to happen on a per-feed basis, and there could be hundreds of feeds. Using a cron job for it risks duplicating a point of failure: if cron is faulty on the installation, causing retrieval events to be lost, then a cron-based fix may also not work. WP ensures that certain cron events exist on every pageload, but this is likely to heavy when we need to check many feeds.
Here I would like a creative solution that will trigger retrieval-event checks regularly, but will do so in a lightweight way. Perhaps something like: on 'init', check against a stored timestamp; if more than an hour has passed since that timestamp, check all feeds. Or store a counter with the timestamp (like max ID) and then, every hour, check only 50 or 100 items and then bump the max_ID; when you reach the end, set it back to zero; in this way, you'd get a full check after a couple hours.
If you have a better idea, please provide a sketch.