Class: Vidibus::Recording::MonitoringJob

Inherits:
Object
  • Object
show all
Defined in:
lib/vidibus/recording/monitoring_job.rb

Constant Summary collapse

INTERVAL =
10.seconds

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ MonitoringJob

Returns a new instance of MonitoringJob.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/vidibus/recording/monitoring_job.rb', line 5

def initialize(args)
  unless @uuid = args[:uuid]
    raise(ArgumentError, 'No recording UUID given')
  end
  unless @class_name = args[:class_name]
    raise(ArgumentError, 'Must provide class name of recording')
  end
  unless @identifier = args[:identifier]
    raise(ArgumentError, 'Must provide identifier of monitoring job')
  end
  ensure_recording
end

Class Method Details

.create(args) ⇒ Object

Returns job



30
31
32
33
# File 'lib/vidibus/recording/monitoring_job.rb', line 30

def self.create(args)
  job = new(args)
  Delayed::Job.enqueue(job)
end

Instance Method Details

#performObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/vidibus/recording/monitoring_job.rb', line 18

def perform
  r = recording.reload
  return unless r.monitoring_job_identifier == @identifier
  if r.worker_running?
    r.track_progress
    run_again
  elsif !r.stopped?
    r.resume
  end
end