Class Sidekiq::Cron::Job
In: lib/sidekiq/cron/job.rb
Parent: Object

Methods

Included Modules

Util

Constants

REMEMBER_THRESHOLD = 24 * 60 * 60   how long we would like to store informations about previous enqueues
LAST_ENQUEUE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z'

Attributes

args  [RW] 
cron  [RW] 
description  [RW] 
fetch_missing_args  [R] 
klass  [RW] 
last_enqueue_time  [R] 
message  [RW] 
name  [RW] 

Public Class methods

get all cron jobs

create new instance of cron job

remove all job from cron

remove "removed jobs" between current jobs and new jobs

load cron jobs from Array input structure should look like: [

  {
    'name'        => 'name_of_job',
    'class'       => 'MyClass',
    'cron'        => '1 * * * *',
    'args'        => '(OPTIONAL) [Array or Hash]',
    'description' => '(OPTIONAL) Description of job'
  },
  {
    'name'  => 'Cool Job for Second Class',
    'class' => 'SecondClass',
    'cron'  => '*/5 * * * *'
  }

]

like to {load_from_array} If exists old jobs in redis but removed from args, destroy old jobs

load cron jobs from Hash input structure should look like: {

  'name_of_job' => {
    'class'       => 'MyClass',
    'cron'        => '1 * * * *',
    'args'        => '(OPTIONAL) [Array or Hash]',
    'description' => '(OPTIONAL) Description of job'
  },
  'My super iber cool job' => {
    'class' => 'SecondClass',
    'cron'  => '*/5 * * * *'
  }

}

like to {load_from_hash} If exists old jobs in redis but removed from args, destroy old jobs

Public Instance methods

active job has different structure how it is loading data from sidekiq queue, it createaswrapper arround job

remove job from cron jobs by name input:

  first arg: name (string) - name of job (must be same - case sensitive)

enque cron job to queue

Parse cron specification ’* * * * *’ and returns time when last run should be performed

remove previous informations about run times this will clear redis and make sure that redis will not overflow with memory

add job to cron jobs input:

  name: (string) - name of job
  cron: (string: '* * * * *' - cron specification when to run job
  class: (string|class) - which class to perform

optional input:

  queue: (string) - which queue to use for enquing (will override class queue)
  args: (array|hash|nil) - arguments for permorm method

crucial part of whole enquing job

siodekiq worker message

test if job should be enqued If yes add it to queue

export job data to hash

[Validate]