Permalink
Browse files

Merge pull request #1 from treeder/master

Minor changes to README and to use new iron.json configs
  • Loading branch information...
2 parents 79ccf82 + aa1496a commit 810fd1f7df96164229cda1c8e32d36b73d409844 @thousandsofthem committed Jun 26, 2012
Showing with 27 additions and 28 deletions.
  1. +1 −1 Gemfile
  2. +16 −10 README.md
  3. +1 −1 Rakefile
  4. +9 −16 lib/delayed/backend/worker.rb
View
@@ -5,5 +5,5 @@ gem 'delayed_job', '~> 3.0.0'
group :development do
gem 'rspec', '>= 2.0'
- gem 'jeweler', '~> 1.8.3'
+ gem 'jeweler2'
end
View
@@ -18,20 +18,16 @@ gem 'delayed_job'
gem 'delayed_job_ironmq'
```
-And add an initializer (`config/initializers/delayed_job_config.rb`):
+And add an initializer (`config/initializers/delayed_job.rb`):
```ruby
Delayed::Worker.configure do |config|
- config.token = 'XXXXXXXXXXXXXXXX'
- config.project_id = 'XXXXXXXXXXXXXXXX'
-
# optional params:
config.available_priorities = [-1,0,1,2] # Default is [0]. Please note, each new priority will speed down a bit picking job from queue
config.queue_name = 'default' # Specify an alternative queue name
config.delay = 0 # Time to wait before message will be available on the queue
config.timeout = 5.minutes # The time in seconds to wait after message is taken off the queue, before it is put back on. Delete before :timeout to ensure it does not go back on the queue.
config.expires_in = 7.days # After this time, message will be automatically removed from the queue.
- end
end
```
@@ -42,18 +38,28 @@ That's it. Use [delayed_job as normal](http://github.com/collectiveidea/delayed_
Example:
```ruby
-class TestJob < Struct.new(:a, :b)
- def perform
- puts a/b
+class User
+ def background_stuff
+ puts "I run in the background"
end
end
-Delayed::Job.enqueue TestJob.new(10, 2)
+```
+
+Then in one of your controllers:
+```ruby
+user = User.new
+user.delay.bg_stuff
```
+# Using with Heroku
+
+To use with Heroku, just add the [IronMQ Add-on](https://addons.heroku.com/iron_mq) and
+you're good to go.
+
# Documentation
You can find more documentation here:
* http://iron.io
-* http://dev.iron.io
+* http://dev.iron.io
View
@@ -12,7 +12,7 @@ rescue Bundler::BundlerError => e
end
require 'rake'
-require 'jeweler'
+require 'jeweler2'
Jeweler::Tasks.new do |gem|
gem.name = "delayed_job_ironmq"
@@ -8,24 +8,17 @@ class << self
def configure
yield(config)
- if config && config.token && config.project_id
- Delayed::Worker.ironmq = IronMQ::Client.new(
- 'token' => config.token,
- 'project_id' => config.project_id
- )
- self.queue_name = config.queue_name || 'default'
- self.delay = config.delay || 0
- self.timeout = config.timeout || 5.minutes
- self.expires_in = config.expires_in || 7.days
+ Delayed::Worker.ironmq = IronMQ::Client.new()
+ self.queue_name = config.queue_name || 'default'
+ self.delay = config.delay || 0
+ self.timeout = config.timeout || 5.minutes
+ self.expires_in = config.expires_in || 7.days
- priorities = config.available_priorities || [0]
- if priorities.include?(0) && priorities.all?{|p|p.is_a?(Integer)}
- self.available_priorities = priorities.sort
- else
- raise ArgumentError, "available_priorities option has wrong format. Please provide array of Integer values, includes zero. Default is [0]."
- end
+ priorities = config.available_priorities || [0]
+ if priorities.include?(0) && priorities.all? { |p| p.is_a?(Integer) }
+ self.available_priorities = priorities.sort
else
- raise ArgumentError, "Required option missing. Please provide both 'token' and 'project_id'"
+ raise ArgumentError, "available_priorities option has wrong format. Please provide array of Integer values, includes zero. Default is [0]."
end
end

0 comments on commit 810fd1f

Please sign in to comment.