aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock32
-rw-r--r--README.md7
-rw-r--r--Rakefile4
-rw-r--r--lib/active_job/queue_adapters/qu_adapter.rb28
-rw-r--r--test/adapters/qu.rb3
-rw-r--r--test/cases/adapter_test.rb5
7 files changed, 76 insertions, 5 deletions
diff --git a/Gemfile b/Gemfile
index e5b9a8fec6..aa228d5669 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,3 +12,5 @@ gem 'queue_classic'
gem 'sneakers', '0.1.1.pre'
gem 'que'
gem 'backburner'
+gem 'qu-rails', github: "bkeepers/qu", branch: "master"
+gem 'qu-redis'
diff --git a/Gemfile.lock b/Gemfile.lock
index 7dda62c1fe..7dac1c6e88 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,3 +1,16 @@
+GIT
+ remote: git://github.com/bkeepers/qu.git
+ revision: 2175633a834504423368d71cb10fb9f072d76cd2
+ branch: master
+ specs:
+ qu (0.2.0)
+ qu-rails (0.2.0)
+ qu (= 0.2.0)
+ railties (>= 3.2, < 5)
+ qu-redis (0.2.0)
+ qu (= 0.2.0)
+ redis-namespace
+
PATH
remote: .
specs:
@@ -8,6 +21,15 @@ PATH
GEM
remote: https://rubygems.org/
specs:
+ actionpack (4.1.1)
+ actionview (= 4.1.1)
+ activesupport (= 4.1.1)
+ rack (~> 1.5.2)
+ rack-test (~> 0.6.2)
+ actionview (4.1.1)
+ activesupport (= 4.1.1)
+ builder (~> 3.1)
+ erubis (~> 2.7.0)
activemodel (4.1.1)
activesupport (= 4.1.1)
builder (~> 3.1)
@@ -34,6 +56,7 @@ GEM
dante (0.1.5)
delayed_job (4.0.1)
activesupport (>= 3.0, < 4.2)
+ erubis (2.7.0)
i18n (0.6.9)
json (1.8.1)
minitest (5.3.4)
@@ -46,6 +69,13 @@ GEM
rack (1.5.2)
rack-protection (1.5.2)
rack
+ rack-test (0.6.2)
+ rack (>= 1.0)
+ railties (4.1.1)
+ actionpack (= 4.1.1)
+ activesupport (= 4.1.1)
+ rake (>= 0.8.7)
+ thor (>= 0.18.1, < 2.0)
rake (10.3.2)
redis (3.0.7)
redis-namespace (1.4.1)
@@ -99,6 +129,8 @@ DEPENDENCIES
activejob!
backburner
delayed_job
+ qu-rails!
+ qu-redis
que
queue_classic
rake
diff --git a/README.md b/README.md
index 6eb177c113..9644b37119 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ of the request-response cycle, so the user doesn't have to wait on it.
The main point is to ensure that all Rails apps will have a job infrastructure
in place, even if it's in the form of an "immediate runner". We can then have
framework features and other gems build on top of that, without having to worry
-about API differences between Delayed Job and Resque. Picking your queuing
+about API differences between Delayed Job and Resque. Picking your queuing
backend becomes more of an operational concern, then. And you'll be able to
switch between them without having to rewrite your jobs.
@@ -24,7 +24,7 @@ Set the queue adapter for Active Job:
``` ruby
ActiveJob::Base.queue_adapter = :inline # default queue adapter
-# Adapters currently supported: :backburner, :delayed_job, :que, :queue_classic,
+# Adapters currently supported: :backburner, :delayed_job, :qu, :que, :queue_classic,
# :resque, :sidekiq, :sneakers, :sucker_punch
```
@@ -44,7 +44,7 @@ Enqueue a job like so:
```ruby
MyJob.enqueue record # Enqueue a job to be performed as soon the queueing system is free.
-```
+```
```ruby
MyJob.enqueue_at Date.tomorrow.noon, record # Enqueue a job to be performed tomorrow at noon.
@@ -92,6 +92,7 @@ We currently have adapters for:
* [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)
* [QueueClassic](https://github.com/ryandotsmith/queue_classic)
* [Resque 1.x](https://github.com/resque/resque)
diff --git a/Rakefile b/Rakefile
index aa48ea58e4..5780410eda 100644
--- a/Rakefile
+++ b/Rakefile
@@ -20,11 +20,11 @@ task default: :test
desc 'Run all adapter tests'
task :test do
- tasks = %w(test_inline test_delayed_job test_que test_queue_classic test_resque test_sidekiq test_sneakers test_sucker_punch test_backburner)
+ tasks = %w(test_inline test_delayed_job test_qu test_que test_queue_classic test_resque test_sidekiq test_sneakers test_sucker_punch test_backburner)
run_without_aborting(*tasks)
end
-%w(inline delayed_job que queue_classic resque sidekiq sneakers sucker_punch backburner).each do |adapter|
+%w(inline delayed_job qu que queue_classic resque sidekiq sneakers sucker_punch backburner).each do |adapter|
Rake::TestTask.new("test_#{adapter}") do |t|
t.libs << 'test'
t.test_files = FileList['test/cases/**/*_test.rb']
diff --git a/lib/active_job/queue_adapters/qu_adapter.rb b/lib/active_job/queue_adapters/qu_adapter.rb
new file mode 100644
index 0000000000..7e69229801
--- /dev/null
+++ b/lib/active_job/queue_adapters/qu_adapter.rb
@@ -0,0 +1,28 @@
+require 'qu'
+
+module ActiveJob
+ module QueueAdapters
+ class QuAdapter
+ class << self
+ def enqueue(job, *args)
+ Qu::Payload.new(klass: JobWrapper, args: [job, *args], queue: job.queue_name).push
+ end
+
+ def enqueue_at(job, timestamp, *args)
+ raise NotImplementedError
+ end
+ end
+
+ class JobWrapper < Qu::Job
+ def initialize(job, *args)
+ @job = job
+ @args = args
+ end
+
+ def perform
+ @job.new.execute *@args
+ end
+ end
+ end
+ end
+end
diff --git a/test/adapters/qu.rb b/test/adapters/qu.rb
new file mode 100644
index 0000000000..7728c843b4
--- /dev/null
+++ b/test/adapters/qu.rb
@@ -0,0 +1,3 @@
+require 'qu-immediate'
+
+ActiveJob::Base.queue_adapter = :qu
diff --git a/test/cases/adapter_test.rb b/test/cases/adapter_test.rb
index 703058dacb..7f6f4c1159 100644
--- a/test/cases/adapter_test.rb
+++ b/test/cases/adapter_test.rb
@@ -14,6 +14,11 @@ class AdapterTest < ActiveSupport::TestCase
assert_equal ActiveJob::QueueAdapters::DelayedJobAdapter, ActiveJob::Base.queue_adapter
end
+ test 'should load Qu adapter' do
+ ActiveJob::Base.queue_adapter = :qu
+ assert_equal ActiveJob::QueueAdapters::QuAdapter, ActiveJob::Base.queue_adapter
+ end
+
test 'should load Que adapter' do
ActiveJob::Base.queue_adapter = :que
assert_equal ActiveJob::QueueAdapters::QueAdapter, ActiveJob::Base.queue_adapter