Module: Creeper::Legacy::ClassMethods

Included in:
Creeper
Defined in:
lib/creeper/legacy.rb

Instance Method Summary collapse

Instance Method Details

#enqueue(job, *args) ⇒ Object



10
11
12
# File 'lib/creeper/legacy.rb', line 10

def enqueue(job, *args)
  enqueue!(job, *args)
end

#enqueue!(job, *args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/creeper/legacy.rb', line 14

def enqueue!(job, *args)
  options     = args.last.is_a?(Hash) ? args.last : {}
  priority    = options[:priority] || options[:pri] || 65536
  delay       = [ 0, options[:delay].to_i ].max
  time_to_run = options[:time_to_run] || options[:ttr] || 120

  klass = options[:class] || job_descriptions[job]

  Creeper::Client.push({
    'queue'       => job,
    'args'        => args,
    'class'       => klass,
    'delay'       => delay,
    'priority'    => priority,
    'time_to_run' => time_to_run
  })
end

#job_descriptionsObject



6
7
8
# File 'lib/creeper/legacy.rb', line 6

def job_descriptions
  @job_descriptions ||= {}
end