Permalink
Browse files

Add Sidekiq for background jobs

  • Loading branch information...
jamesdabbs committed May 21, 2014
1 parent cbc86ea commit 7f18f3df8e5d320486afb9eb388fac0d2bbf0d60
Showing with 27 additions and 3 deletions.
  1. +2 −0 Gemfile
  2. +14 −0 Gemfile.lock
  3. +2 −2 README.md
  4. +1 −1 app/models/user.rb
  5. +8 −0 app/workers/cat_request_worker.rb
View
@@ -15,6 +15,8 @@ gem 'devise'
gem 'httparty'
gem 'nokogiri'
gem 'sidekiq'
group :development do
gem 'pry'
gem 'spring'
View
@@ -37,6 +37,8 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
celluloid (0.15.2)
timers (~> 1.1.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
@@ -45,6 +47,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
connection_pool (2.0.0)
devise (3.2.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@@ -106,6 +109,9 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
redis (3.0.7)
redis-namespace (1.4.1)
redis (~> 3.0.4)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
@@ -124,6 +130,12 @@ GEM
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0)
sidekiq (3.0.2)
celluloid (>= 0.15.2)
connection_pool (>= 2.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
@@ -150,6 +162,7 @@ GEM
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
timers (1.1.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
@@ -179,6 +192,7 @@ DEPENDENCIES
rails (= 4.1.0)
rspec-rails
sass-rails (~> 4.0.3)
sidekiq
slim-rails
spring
spring-commands-rspec
View
@@ -28,8 +28,8 @@ Note that (in the interest of not actually depending on outside services), "serv
## Project Goals
* [ ] Select a queue backend
* [ ] Run `CatRequest#fulfill!` in the background
* [x] Select a queue backend
* [x] Run `CatRequest#fulfill!` in the background
* [ ] Make sure specs still pass
* [x] Bonus: find a better way of spec'ing the `open` system call
* [ ] Install a job administration system
View
@@ -8,6 +8,6 @@ class User < ActiveRecord::Base
def cat_me!
req = cat_requests.create!
req.fulfill
CatRequestWorker.perform_async req.id
end
end
@@ -0,0 +1,8 @@
class CatRequestWorker
include Sidekiq::Worker
def perform id
cat_request = CatRequest.find id
cat_request.fulfill
end
end

0 comments on commit 7f18f3d

Please sign in to comment.