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 49
49:         def after_fork
50:         end

Hook method that is called before a new worker is forked

[Source]

    # File lib/delayed/backend/base.rb, line 45
45:         def before_fork
46:         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.create(options).tap do |job|
29:               job.hook(:enqueue)
30:             end
31:           else
32:             options[:payload_object].perform
33:           end
34:         end

[Source]

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

[Source]

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

[Validate]