Module: Que::JobMethods

Included in:
ActiveJob::JobExtensions, Job
Defined in:
lib/que/job_methods.rb

Instance Method Summary collapse

Instance Method Details

#_run(args: nil, kwargs: nil, reraise_errors: false) ⇒ Object

Run the job with error handling and cleanup logic. Optionally support overriding the args, because it’s necessary when jobs are invoked from ActiveJob.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/que/job_methods.rb', line 42

def _run(args: nil, kwargs: nil, reraise_errors: false)
  if args.nil? && que_target
    args = que_target.que_attrs.fetch(:args)
  end

  if kwargs.nil? && que_target
    kwargs = que_target.que_attrs.fetch(:kwargs)
  end

  run(*args, **kwargs)
  default_resolve_action if que_target && !que_target.que_resolved
rescue => error
  raise error unless que_target

  que_target.que_error = error

  run_error_notifier =
    begin
      handle_error(error)
    rescue => error_2
      Que.notify_error(error_2, que_target.que_attrs)
      true
    end

  Que.notify_error(error, que_target.que_attrs) if run_error_notifier
  retry_in_default_interval unless que_target.que_resolved

  raise error if reraise_errors
end

#log_level(elapsed) ⇒ Object



72
73
74
# File 'lib/que/job_methods.rb', line 72

def log_level(elapsed)
  :debug
end