aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/queue_adapters.rb
blob: bd69e525bbaa0efca1c8a41c32a4d9d953cdec3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
module ActiveJob
  # == Active Job adapters
  #
  # Active Job has adapters for the following queueing backends:
  #
  # * {Backburner}[https://github.com/nesquena/backburner]
  # * {Delayed Job}[https://github.com/collectiveidea/delayed_job]
  # * {Qu}[https://github.com/bkeepers/qu]
  # * {Que}[https://github.com/chanks/que]
  # * {queue_classic}[https://github.com/QueueClassic/queue_classic]
  # * {Resque 1.x}[https://github.com/resque/resque/tree/1-x-stable]
  # * {Sidekiq}[http://sidekiq.org]
  # * {Sneakers}[https://github.com/jondot/sneakers]
  # * {Sucker Punch}[https://github.com/brandonhilkert/sucker_punch]
  #
  # === Backends Features
  #
  #   |                   | Async | Queues | Delayed   | Priorities | Timeout | Retries |
  #   |-------------------|-------|--------|-----------|------------|---------|---------|
  #   | Backburner        | Yes   | Yes    | Yes       | Yes        | Job     | Global  |
  #   | Delayed Job       | Yes   | Yes    | Yes       | Job        | Global  | Global  |
  #   | Qu                | Yes   | Yes    | No        | No         | No      | Global  |
  #   | Que               | Yes   | Yes    | Yes       | Job        | No      | Job     |
  #   | queue_classic     | Yes   | Yes    | No*       | No         | No      | No      |
  #   | Resque            | Yes   | Yes    | Yes (Gem) | Queue      | Global  | Yes     |
  #   | Sidekiq           | Yes   | Yes    | Yes       | Queue      | No      | Job     |
  #   | Sneakers          | Yes   | Yes    | No        | Queue      | Queue   | No      |
  #   | Sucker Punch      | Yes   | Yes    | No        | No         | No      | No      |
  #   | Active Job Inline | No    | Yes    | N/A       | N/A        | N/A     | N/A     |
  #
  # ==== Async
  #
  # Yes: The Queue Adapter runs the jobs in a separate or forked process.
  #
  # No: The job is run in the same process.
  #
  # ==== Queues
  #
  # Yes: Jobs may set which queue they are run in with queue_as or by using the set
  # method.
  #
  # ==== Delayed
  #
  # Yes: The adapter will run the job in the future through perform_later.
  #
  # (Gem): An additional gem is required to use perform_later with this adapter.
  #
  # No: The adapter will run jobs at the next opportunity and cannot use perform_later.
  #
  # N/A: The adapter does not support queueing.
  #
  # NOTE:
  # queue_classic does not support job scheduling.
  # However, you can use the queue_classic-later gem.
  # See the documentation for ActiveJob::QueueAdapters::QueueClassicAdapter.
  #
  # ==== Priorities
  #
  # The order in which jobs are processed can be configured differently depending
  # on the adapter.
  #
  # Job: Any class inheriting from the adapter may set the priority on the job
  # object relative to other jobs.
  #
  # Queue: The adapter can set the priority for job queues, when setting a queue
  # with Active Job this will be respected.
  #
  # Yes: Allows the priority to be set on the job object, at the queue level or
  # as default configuration option.
  #
  # No: Does not allow the priority of jobs to be configured.
  #
  # N/A: The adapter does not support queueing, and therefore sorting them.
  #
  # ==== Timeout
  #
  # When a job will stop after the allotted time.
  #
  # Job: The timeout can be set for each instance of the job class.
  #
  # Queue: The timeout is set for all jobs on the queue.
  #
  # Global: The adapter is configured that all jobs have a maximum run time.
  #
  # N/A: This adapter does not run in a separate process, and therefore timeout
  # is unsupported.
  #
  # ==== Retries
  #
  # Job: The number of retries can be set per instance of the job class.
  #
  # Yes: The Number of retries can be configured globally, for each instance or
  # on the queue. This adapter may also present failed instances of the job class
  # that can be restarted.
  #
  # Global: The adapter has a global number of retries.
  #
  # N/A: The adapter does not run in a separate process, and therefore doesn't
  # support retries.
  module QueueAdapters
    extend ActiveSupport::Autoload

    autoload :InlineAdapter
    autoload :BackburnerAdapter
    autoload :DelayedJobAdapter
    autoload :QuAdapter
    autoload :QueAdapter
    autoload :QueueClassicAdapter
    autoload :ResqueAdapter
    autoload :SidekiqAdapter
    autoload :SneakersAdapter
    autoload :SuckerPunchAdapter
    autoload :TestAdapter

    ADAPTER = 'Adapter'.freeze
    private_constant :ADAPTER

    class << self
      def lookup(name)
        const_get(name.to_s.camelize << ADAPTER)
      end
    end
  end
end