lib/rocket_job/job.rb in rocketjob-1.1.0 vs lib/rocket_job/job.rb in rocketjob-1.1.1
- old
+ new
@@ -320,11 +320,11 @@
self.arguments = arguments.collect { |i| i.is_a?(BSON::OrderedHash) ? i.with_indifferent_access : i }
end
end
# Set exception information for this job and fail it
- def fail!(worker_name='user', exc_or_message='Job failed through user action')
+ def fail(worker_name='user', exc_or_message='Job failed through user action')
if exc_or_message.is_a?(Exception)
self.exception = JobException.from_exception(exc_or_message)
exception.worker_name = worker_name
else
build_exception(
@@ -333,11 +333,16 @@
backtrace: [],
worker_name: worker_name
)
end
# not available as #super
- aasm.current_event = :fail!
- aasm_fire_event(:fail, persist: true)
+ aasm.current_event = :fail
+ aasm_fire_event(:fail, persist: false)
+ end
+
+ def fail!(worker_name='user', exc_or_message='Job failed through user action')
+ self.fail(worker_name, exc_or_message)
+ save!
end
# Requeue this running job since the worker assigned to it has died
def requeue!(worker_name_=nil)
return false if worker_name_ && (worker_name != worker_name_)