Module: Lux::DelayedJob

Extended by:
DelayedJob
Included in:
DelayedJob
Defined in:
lib/lux/delayed_job/lib/redis.rb,
lib/lux/delayed_job/delayed_job.rb

Defined Under Namespace

Modules: Memory, NSQ, Postgre, Redis

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#serverObject

Returns the value of attribute server.



4
5
6
# File 'lib/lux/delayed_job/delayed_job.rb', line 4

def server
  @server
end

Instance Method Details

#popObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lux/delayed_job/delayed_job.rb', line 20

def pop
  obj, method_to_call = @server.pop

  return unless obj

  puts "JOB POP> #{obj.to_s}.#{method_to_call}".yellow

  if method_to_call
    begin
      obj.send(method_to_call)
    rescue
      puts("Lux::DelayedJob.pop FAIL for :#{method_to_call} (#{$!.message})".red)
    end
  else
    eval(obj)
  end

  true
end

#push(object, method_to_call = nil) ⇒ Object



15
16
17
18
# File 'lib/lux/delayed_job/delayed_job.rb', line 15

def push object, method_to_call=nil
  die "No DelayedJob server defined" unless @server
  @server.push [object, method_to_call]
end

#run!(seconds = 1) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/lux/delayed_job/delayed_job.rb', line 40

def run! seconds=1
  puts "JOB QUE> is running for #{@server}".green

  Thread.new do
    while true
      print '.'
      true while Lux::DelayedJob.pop
      sleep seconds
    end
  end.join
end