Module Delayed::Backend::Base::ClassMethods
In: lib/delayed/backend/base.rb

Methods

Public Instance methods

Hook method that is called after a new worker is forked

[Source]

    # File lib/delayed/backend/base.rb, line 54
54:         def after_fork
55:         end

Hook method that is called before a new worker is forked

[Source]

    # File lib/delayed/backend/base.rb, line 50
50:         def before_fork
51:         end

Add a job to the queue

[Source]

    # File lib/delayed/backend/base.rb, line 10
10:         def enqueue(*args)
11:           options = {
12:             :priority => Delayed::Worker.default_priority
13:           }.merge!(args.extract_options!)
14: 
15:           options[:payload_object] ||= args.shift
16: 
17:           if args.size > 0
18:             warn "[DEPRECATION] Passing multiple arguments to `#enqueue` is deprecated. Pass a hash with :priority and :run_at."
19:             options[:priority] = args.first || options[:priority]
20:             options[:run_at]   = args[1]
21:           end
22: 
23:           unless options[:payload_object].respond_to?(:perform)
24:             raise ArgumentError, 'Cannot enqueue items which do not respond to perform'
25:           end
26: 
27:           if Delayed::Worker.delay_jobs
28:             self.new(options).tap do |job|
29:               Delayed::Worker.lifecycle.run_callbacks(:enqueue, job) do
30:                 job.hook(:enqueue)
31:                 job.save
32:               end
33:             end
34:           else
35:             Delayed::Job.new(:payload_object => options[:payload_object]).tap do |job|
36:               job.invoke_job
37:             end
38:           end
39:         end

[Source]

    # File lib/delayed/backend/base.rb, line 41
41:         def reserve(worker, max_run_time = Worker.max_run_time)
42:           # We get up to 5 jobs from the db. In case we cannot get exclusive access to a job we try the next.
43:           # this leads to a more even distribution of jobs across the worker processes
44:           find_available(worker.name, worker.read_ahead, max_run_time).detect do |job|
45:             job.lock_exclusively!(max_run_time, worker.name)
46:           end
47:         end

[Source]

    # File lib/delayed/backend/base.rb, line 57
57:         def work_off(num = 100)
58:           warn "[DEPRECATION] `Delayed::Job.work_off` is deprecated. Use `Delayed::Worker.new.work_off instead."
59:           Delayed::Worker.new.work_off(num)
60:         end

[Validate]