PhoenixKit.Jobs (phoenix_kit v1.7.42)

Copy Markdown View Source

Jobs module for PhoenixKit.

This module provides functions for managing the Jobs admin interface. When enabled, it shows a view-only dashboard of job status and history.

Core Functions

System Control

Settings Keys

All configuration is stored in the Settings system:

  • jobs_enabled - Enable/disable Jobs admin interface (boolean)

Usage Examples

# Check if Jobs module is enabled
if PhoenixKit.Jobs.enabled?() do
  # Show jobs dashboard
end

# Enable/disable the module
PhoenixKit.Jobs.enable_system()
PhoenixKit.Jobs.disable_system()

Summary

Functions

Disables the Jobs module.

Enables the Jobs module.

Returns true when the Jobs module is enabled.

Returns the current Jobs module configuration as a map.

Returns job statistics from the Oban jobs table.

Functions

disable_system()

@spec disable_system() :: {:ok, any()} | {:error, any()}

Disables the Jobs module.

Examples

iex> PhoenixKit.Jobs.disable_system()
{:ok, %PhoenixKit.Settings.Setting{}}

enable_system()

@spec enable_system() :: {:ok, any()} | {:error, any()}

Enables the Jobs module.

Examples

iex> PhoenixKit.Jobs.enable_system()
{:ok, %PhoenixKit.Settings.Setting{}}

enabled?()

@spec enabled?() :: boolean()

Returns true when the Jobs module is enabled.

Examples

iex> PhoenixKit.Jobs.enabled?()
false

iex> PhoenixKit.Jobs.enable_system()
iex> PhoenixKit.Jobs.enabled?()
true

get_config()

@spec get_config() :: map()

Returns the current Jobs module configuration as a map.

Examples

iex> PhoenixKit.Jobs.get_config()
%{
  enabled: true,
  stats: %{
    available: 0,
    scheduled: 0,
    executing: 0,
    completed: 0,
    retryable: 0,
    discarded: 0,
    cancelled: 0
  }
}

get_job_stats()

@spec get_job_stats() :: map()

Returns job statistics from the Oban jobs table.

Examples

iex> PhoenixKit.Jobs.get_job_stats()
%{available: 5, scheduled: 2, executing: 1, completed: 100, ...}