Skip to content

Commit

Permalink
Merge remote branch 'collectiveidea/master' into delayed_job_daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
guns committed Nov 27, 2010
2 parents 194291d + f4fc9a2 commit 324ce6e
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 326 deletions.
64 changes: 64 additions & 0 deletions CHANGELOG
@@ -0,0 +1,64 @@
2.1.1 - 2010-11-14
* Fix issue with worker name not getting properly set when locking a job
* Fixes for YAML serialization

2.1.0 - 2010-11-14
* Added enqueue, before, after, success, error, and failure. See the README
* Remove Merb support
* Remove all non Active Record backends into separate gems. See https://github.com/collectiveidea/delayed_job/wiki/Backends
* remove rails 2 support. delayed_job 2.1 will only support Rails 3
* New pure-YAML serialization
* Added Rails 3 railtie and generator
* Changed @@sleep_delay to self.class.sleep_delay to be consistent with other class variable usage
* Added --sleep-delay command line option

2.0.4 - 2010-11-14
* Fix issue where dirty tracking prevented job from being properly unlocked
* Add delayed_job_args variable for Capistrano recipe to allow configuration of started workers (e.g. "-n 2 --max-priority 10")
* Added options to handle_asynchronously
* Added Delayed::Worker.default_priority
* Allow private methods to be delayed
* Fixes for Ruby 1.9
* Added -m command line option to start a monitor process
* normalize logging in worker
* Deprecate #send_later and #send_at in favor of new #delay method
* Added @#delay@ to Object that allows you to delay any method and pass options:
options = {:priority => 19, :run_at => 5.minutes.from_now}
UserMailer.delay(options).deliver_confirmation(@user)

2.0.3 - 2010-04-16

* Fix initialization for Rails 2.x

2.0.2 - 2010-04-08

* Fixes to Mongo Mapper backend [ "14be7a24":http://github.com/collectiveidea/delayed_job/commit/14be7a24, "dafd5f46":http://github.com/collectiveidea/delayed_job/commit/dafd5f46, "54d40913":http://github.com/collectiveidea/delayed_job/commit/54d40913 ]
* DataMapper backend performance improvements [ "93833cce":http://github.com/collectiveidea/delayed_job/commit/93833cce, "e9b1573e":http://github.com/collectiveidea/delayed_job/commit/e9b1573e, "37a16d11":http://github.com/collectiveidea/delayed_job/commit/37a16d11, "803f2bfa":http://github.com/collectiveidea/delayed_job/commit/803f2bfa ]
* Fixed Delayed::Command to create tmp/pids directory [ "8ec8ca41":http://github.com/collectiveidea/delayed_job/commit/8ec8ca41 ]
* Railtie to perform Rails 3 initialization [ "3e0fc41f":http://github.com/collectiveidea/delayed_job/commit/3e0fc41f ]
* Added on_permanent_failure hook [ "d2f14cd6":http://github.com/collectiveidea/delayed_job/commit/d2f14cd6 ]

2.0.1 - 2010-04-03
* Bug fix for using ActiveRecord backend with daemon [martinbtt]

2.0.0 - 2010-04-03
* Multiple backend support (See README for more details)
* Added MongoMapper backend [zbelzer, moneypools]
* Added DataMapper backend [lpetre]
* Reverse priority so the jobs table can be indexed. Lower numbers have higher priority. The default priority is 0, so increase it for jobs that are not important.
* Move most of the heavy lifting from Job to Worker (#work_off, #reschedule, #run, #min_priority, #max_priority, #max_run_time, #max_attempts, #worker_name) [albus522]
* Remove EvaledJob. Implement your own if you need this functionality.
* Only use Time.zone if it is set. Closes #20
* Fix for last_error recording when destroy_failed_jobs = false, max_attempts = 1
* Implemented worker name_prefix to maintain dynamic nature of pid detection
* Some Rails 3 compatibility fixes [fredwu]

1.8.5 - 2010-03-15

* Set auto_flushing=true on Rails logger to fix logging in production
* Fix error message when trying to send_later on a method that doesn't exist
* Don't use rails_env in capistrano if it's not set. closes #22
* Delayed job should append to delayed_job.log not overwrite
* Version bump to 1.8.5
* fixing Time.now to be Time.zone.now if set to honor the app set local TimeZone
* Replaced @Worker::SLEEP@, @Job::MAX_ATTEMPTS@, and @Job::MAX_RUN_TIME@ with class methods that can be overridden.
108 changes: 58 additions & 50 deletions Gemfile.lock
@@ -1,84 +1,92 @@
PATH
remote: .
specs:
delayed_job (2.1.0.pre2)
delayed_job (2.1.1)
activesupport (~> 3.0)
daemons

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (= 3.0.0)
mail (~> 2.2.5)
actionpack (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.0)
activesupport (= 3.0.0)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
arel (~> 1.0.0)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.4)
builder (2.1.2)
columnize (0.3.1)
columnize (0.3.2)
daemons (1.1.0)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.1)
i18n (0.4.2)
linecache (0.43)
mail (2.2.6)
mail (2.2.10)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
i18n (~> 0.4.1)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mysql (2.8.1)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.4)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
actionpack (= 3.0.0)
activerecord (= 3.0.0)
activeresource (= 3.0.0)
activesupport (= 3.0.0)
bundler (~> 1.0.0)
railties (= 3.0.0)
railties (3.0.0)
actionpack (= 3.0.0)
activesupport (= 3.0.0)
rake (>= 0.8.4)
thor (~> 0.14.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rspec (1.3.0)
ruby-debug (0.10.3)
rspec (2.1.0)
rspec-core (~> 2.1.0)
rspec-expectations (~> 2.1.0)
rspec-mocks (~> 2.1.0)
rspec-core (2.1.0)
rspec-expectations (2.1.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.1.0)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
sqlite3-ruby (1.3.1)
thor (0.14.0)
treetop (1.4.8)
sqlite3-ruby (1.3.2)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)

Expand All @@ -92,6 +100,6 @@ DEPENDENCIES
mysql
rails (~> 3.0)
rake
rspec
rspec (~> 2.0)
ruby-debug
sqlite3-ruby
45 changes: 8 additions & 37 deletions README.textile
Expand Up @@ -14,47 +14,24 @@ It is a direct extraction from Shopify where the job table is responsible for a

h2. Installation

To install as a gem, add the following to @config/environment.rb@:
delayed_job 2.1 only supports Rails 3.0+. See the "2.0 branch":https://github.com/collectiveidea/delayed_job/tree/v2.0 for Rails 2.

<pre>
config.gem 'delayed_job'
</pre>

Rake tasks are not automatically loaded from gems, so you'll need to add the following to your Rakefile:

<pre>
begin
require 'delayed/tasks'
rescue LoadError
STDERR.puts "Run `rake gems:install` to install delayed_job"
end
</pre>

To install as a plugin:
To install, add delayed_job to your @Gemfile@ and run `bundle install`:

<pre>
script/plugin install git://github.com/collectiveidea/delayed_job.git
gem 'delayed_job'
</pre>

After delayed_job is installed, you will need to setup the backend.

h2. Rails

As of delayed_job 2.1 it only supports Rails 3.0+.

The 2.0.x gems work great with older versions of Rails, so check those out if you need them.


h2. Backends

delayed_job supports multiple backends for storing the job queue. "See the wiki for other backends":http://wiki.github.com/collectiveidea/delayed_job/backends besides Active Record.

h3. Active Record

The default is Active Record, which requires a jobs table.

<pre>
$ script/generate delayed_job
$ script/rails generate delayed_job
$ rake db:migrate
</pre>

Expand All @@ -67,7 +44,7 @@ Call @.delay.method(params)@ on any object and it will be processed in the backg
Notifier.deliver_signup(@user)

# with delayed_job
Notifier.delay.deliver_signup @user
Notifier.delay.signup(@user)
</pre>

If a method should always be run in the background, you can call @#handle_asynchronously@ after the method declaration:
Expand Down Expand Up @@ -237,19 +214,13 @@ h2. How to contribute

If you find what looks like a bug:

# Check the GitHub issue tracker to see if anyone else has had the same issue.
http://github.com/collectiveidea/delayed_job/issues/
# Search the "mailing list":http://groups.google.com/group/delayed_job to see if anyone else had the same issue.
# Check the "GitHub issue tracker":http://github.com/collectiveidea/delayed_job/issues/ to see if anyone else has reported issue.
# If you don't see anything, create an issue with information on how to reproduce it.

If you want to contribute an enhancement or a fix:

# Fork the project on github.
http://github.com/collectiveidea/delayed_job/
# Make your changes with tests.
# Commit the changes without making changes to the Rakefile, VERSION, or any other files that aren't related to your enhancement or fix
# Commit the changes without making changes to the Rakefile or any other files that aren't related to your enhancement or fix
# Send a pull request.

h3. Changelog

See http://wiki.github.com/collectiveidea/delayed_job/changelog for a list of changes.

8 changes: 3 additions & 5 deletions Rakefile
Expand Up @@ -2,12 +2,10 @@
require 'rubygems'
require 'bundler/setup'

require 'spec/rake/spectask'
require 'rspec/core/rake_task'
desc 'Run the specs'
Spec::Rake::SpecTask.new(:spec) do |t|
t.libs << 'lib'
t.pattern = 'spec/*_spec.rb'
t.verbose = true
RSpec::Core::RakeTask.new do |r|
r.verbose = false
end

task :default => :spec
4 changes: 2 additions & 2 deletions delayed_job.gemspec
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = 'delayed_job'
s.version = '2.1.0.pre2'
s.version = '2.1.1'
s.authors = ["Brandon Keepers", "Tobias L\303\274tke"]
s.summary = 'Database-backed asynchronous priority queue system -- Extracted from Shopify'
s.description = "Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks.
Expand All @@ -19,7 +19,7 @@ This gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job)

s.add_runtime_dependency 'daemons'
s.add_runtime_dependency 'activesupport', '~>3.0'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rspec', '~>2.0'
s.add_development_dependency 'rake'
s.add_development_dependency 'rails', '~>3.0'
s.add_development_dependency 'sqlite3-ruby'
Expand Down
20 changes: 4 additions & 16 deletions lib/delayed/backend/active_record.rb
@@ -1,19 +1,5 @@
require 'active_record'

class ActiveRecord::Base
yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"

def self.yaml_new(klass, tag, val)
klass.find(val['attributes']['id'])
rescue ActiveRecord::RecordNotFound
nil
end

def to_yaml_properties
['@attributes']
end
end

module Delayed
module Backend
module ActiveRecord
Expand Down Expand Up @@ -67,8 +53,10 @@ def lock_exclusively!(max_run_time, worker)
self.class.update_all(["locked_at = ?", now], ["id = ? and locked_by = ?", id, worker])
end
if affected_rows == 1
self.locked_at = now
self.locked_by = worker
self.locked_at = now
self.locked_by = worker
self.locked_at_will_change!
self.locked_by_will_change!
return true
else
return false
Expand Down

0 comments on commit 324ce6e

Please sign in to comment.