PhoenixKit.ScheduledJobs.Workers.ProcessScheduledJobsWorker (phoenix_kit v1.7.71)
Copy Markdown View SourceOban worker that processes pending scheduled jobs.
This worker runs every minute via Oban's cron plugin and processes all
scheduled jobs that are due for execution. It replaces the single-purpose
PublishScheduledPostsJob with a universal job processor.
Configuration
Add to your Oban cron configuration:
config :your_app, Oban,
plugins: [
{Oban.Plugins.Cron,
crontab: [
{"* * * * *", PhoenixKit.ScheduledJobs.Workers.ProcessScheduledJobsWorker}
]}
]Behavior
- Runs every minute
- Queries all pending jobs where
scheduled_at <= now - Orders by priority (DESC) then scheduled_at (ASC)
- For each job, loads the handler module and calls
execute/2 - Marks jobs as executed or failed based on result
- Logs summary of processed jobs
Error Handling
- Jobs that fail are marked with incremented attempt count
- After max_attempts, job status changes to "failed"
- Exceptions are caught, logged, and treated as failures
- Worker itself always returns :ok to prevent Oban retries