wkentdag / payload-plugin-scheduler

PayloadCMS plugin for scheduled posts
https://www.npmjs.com/package/payload-plugin-scheduler
MIT License
9 stars 2 forks source link

Support other architectures #9

Open wkentdag opened 1 month ago

wkentdag commented 1 month ago

Currently the plugin is only designed for a long-running, single-server environment. Need to support the following cases:

  1. multi-instance (eg load balanced)
  2. ephemeral servers (ie lambda for payload v3) -- lower priority since v3 is still in beta

For ephemeral envs, the plugin should expose a new option like useCron so the consumer can disable the onInit cron behavior. And, should export the init#scanner and lib fns in a way that they can be easily plugged into an API route that can be pinged externally. Last, will need to ensure that eg with a 15min window, a post scheduled for 10:15 will be scheduled at the top of the 10:15-10:30 window (rather than the end of the 10-10:15 window) .

Multi-instance is a little tricker, probably needs several steps:

  1. Wrap the entire scan / schedule / publish flow in a transaction
  2. Add a new scheduled_posts.status like scheduled for posts that have actually been scheduled, exclude them from getPostsToBeScheduled find op
  3. accept a fn through plugin config that allows consumers to hook into / abort the scan / publish operation (ie for a leader/follower setup)
wkentdag commented 1 week ago

This will probably be the move for v3 https://github.com/payloadcms/payload/pull/8228/