Class: RocketJob::Jobs::UploadFileJob

Inherits:
RocketJob::Job show all
Defined in:
lib/rocket_job/jobs/upload_file_job.rb

Overview

Job to upload a file into another job.

Intended for use by DirmonJob to upload a file into a specified job.

Can be used directly for any job class, as long as that job responds to ‘#upload`.

Instance Method Summary collapse

Methods included from Plugins::Job::Throttle

#throttle_filter_class, #throttle_filter_id

Methods included from Plugins::Job::Worker

#fail_on_exception!, #perform_now, #rocket_job_active_workers, #rocket_job_work

Methods included from Plugins::Job::StateMachine

#pausable?

Methods included from Plugins::Job::Persistence

#create_restart!, #reload, #save_with_retry!

Methods included from Plugins::Job::Model

#as_json, #duration, #expired?, #run_now!, #scheduled?, #scheduled_at, #seconds, #sleeping?, #status, #worker_count, #worker_names, #worker_on_server?

Instance Method Details

#performObject

Create the job and upload the file into it.



39
40
41
42
43
44
45
46
47
48
# File 'lib/rocket_job/jobs/upload_file_job.rb', line 39

def perform
  job    = job_class.from_properties(properties)
  job.id = job_id if job_id
  upload_file(job)
  job.save!
rescue Exception => e
  # Prevent partial uploads
  job&.cleanup! if job.respond_to?(:cleanup!)
  raise(e)
end