PhoenixKit.ScheduledJobs.ScheduledJob (phoenix_kit v1.7.62)

Copy Markdown View Source

Schema for scheduled jobs.

Represents a job scheduled to run at a specific time. Jobs are polymorphic and can reference any type of resource (posts, emails, notifications, etc.).

Fields

  • job_type - Type identifier (e.g., "publish_post", "send_email")
  • handler_module - Module that implements PhoenixKit.ScheduledJobs.Handler
  • resource_type - Type of resource (e.g., "post", "email")
  • resource_uuid - UUID of the target resource
  • scheduled_at - When the job should execute
  • executed_at - When the job actually executed (nil if pending)
  • status - Current status: "pending", "executed", "failed", "cancelled"
  • attempts - Number of execution attempts
  • max_attempts - Maximum retry attempts (default: 3)
  • last_error - Error message from last failed attempt
  • args - Additional arguments passed to the handler
  • priority - Execution priority (higher = more urgent)
  • created_by_uuid - Optional user who created the job

Summary

Functions

Changeset for cancelling a job.

Changeset for creating a new scheduled job.

Changeset for marking a job as executed.

Changeset for marking a job as failed.

Changeset for rescheduling a job.

Functions

cancel_changeset(scheduled_job)

Changeset for cancelling a job.

create_changeset(scheduled_job \\ %__MODULE__{}, attrs)

Changeset for creating a new scheduled job.

execute_changeset(scheduled_job)

Changeset for marking a job as executed.

fail_changeset(scheduled_job, error)

Changeset for marking a job as failed.

reschedule_changeset(scheduled_job, new_scheduled_at)

Changeset for rescheduling a job.