Skip to content
Browse files

Convert text files to Markdown

  • Loading branch information...
1 parent 14b18a5 commit 5b5f9710072a57d4f61ce10f7ec15786c22e5809 @sferik sferik committed Jan 25, 2013
Showing with 175 additions and 141 deletions.
  1. +20 −3 CHANGELOG → CHANGELOG.md
  2. +18 −0 CONTRIBUTING.md
  3. +0 −14 CONTRIBUTING.textile
  4. +12 −2 Gemfile
  5. +1 −1 MIT-LICENSE → LICENSE.md
  6. +110 −96 README.textile → README.md
  7. +14 −25 delayed_job.gemspec
View
23 CHANGELOG → CHANGELOG.md
@@ -1,27 +1,32 @@
3.0.4 - 2012-11-09
+==================
* Allow the app to specify a default queue name
* Capistrano script now allows user to specify the DJ command, allowing the user to add "bundle exec" if necessary
* Persisted record check is now more general
3.0.3 - 2012-05-25
+==================
* Fix a bug where the worker would not respect the exit condition
* Properly handle sleep delay command line argument
3.0.2 - 2012-04-02
+==================
* Fix deprecation warnings
* Raise ArgumentError if attempting to enqueue a performable method on an object that hasn't been persisted yet
* Allow the number of jobs read at a time to be configured from the command line using --read-ahead
* Allow custom logger to be configured through Delayed::Worker.logger
* Various documentation improvements
3.0.1 - 2012-01-24
+==================
* Added RecordNotFound message to deserialization error
* Direct JRuby's yecht parser to syck extensions
* Updated psych extensions for better compatibility with ruby 1.9.2
* Updated syck extension for increased compatibility with class methods
* Test grooming
3.0.0 - 2011-12-30
+==================
* New: Named queues
* New: Job/Worker lifecycle callbacks
* Change: daemons is no longer a runtime dependency
@@ -32,14 +37,17 @@
* Fix hooks not getting called when delay_jobs is false
2.1.4 - 2011-02-11
+==================
* Working around issues when psych is loaded, fixes issues with bundler 1.0.10 and Rails 3.0.4
* Added -p/--prefix option to help differentiate multiple delayed job workers on the same host.
2.1.3 - 2011-01-20
+==================
* Revert worker contention fix due to regressions
* Added Delayed::Worker.delay_jobs flag to support running jobs immediately
2.1.2 - 2010-12-01
+==================
* Remove contention between multiple workers by performing an update to lock a job before fetching it
* Job payloads may implement #max_attempts to control how many times it should be retried
* Fix for loading ActionMailer extension
@@ -48,10 +56,12 @@
* Fix `rake jobs:work` so it outputs to the console
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
@@ -62,22 +72,27 @@
* Added --sleep-delay command line option
2.0.8 - Unreleased
+==================
* Backport fix for deserialization errors that bring down the daemon
2.0.7 - 2011-02-10
+==================
* Fixed missing generators and recipes for Rails 2.x
2.0.6 - 2011-01-20
+==================
* Revert worker contention fix due to regressions
2.0.5 - 2010-12-01
+==================
* Added #reschedule_at hook on payload to determine when the job should be rescheduled [backported from 2.1]
* Added --sleep-delay command line option [backported from 2.1]
* Added 'delayed_job_server_role' Capistrano variable to allow delayed_job to run on its own worker server
set :delayed_job_server_role, :worker
* Changed AR backend to reserve jobs using an UPDATE query to reduce worker contention [backported from 2.1]
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
@@ -92,21 +107,23 @@
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]
@@ -119,7 +136,7 @@
* 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
View
18 CONTRIBUTING.md
@@ -0,0 +1,18 @@
+How to contribute
+=================
+
+If you find what looks like a bug:
+
+* 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.
+* Make your changes with tests.
+* 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.
View
14 CONTRIBUTING.textile
@@ -1,14 +0,0 @@
-h2. How to contribute
-
-If you find what looks like a bug:
-
-# 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.
-# Make your changes with tests.
-# 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.
View
14 Gemfile
@@ -1,5 +1,6 @@
-source 'http://rubygems.org'
-gemspec
+source :rubygems
+
+gem 'rake'
platforms :ruby do
gem 'sqlite3'
@@ -9,3 +10,12 @@ platforms :jruby do
gem 'jruby-openssl'
gem 'activerecord-jdbcsqlite3-adapter'
end
+
+group :test do
+ gem 'activerecord', '~> 3.0'
+ gem 'actionmailer', '~> 3.0'
+ gem 'rspec', '>= 2.11'
+ gem 'simplecov'
+end
+
+gemspec
View
2 MIT-LICENSE → LICENSE.md
@@ -1,4 +1,4 @@
-Copyright (c) 2005 Tobias Luetke
+Copyright (c) 2005 Tobias Lütke
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
206 README.textile → README.md
@@ -1,8 +1,19 @@
-h1. Delayed::Job "!https://travis-ci.org/collectiveidea/delayed_job.png!":http://travis-ci.org/collectiveidea/delayed_job "!https://gemnasium.com/collectiveidea/delayed_job.png?travis!":https://gemnasium.com/collectiveidea/delayed_job
-
-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. Amongst those tasks are:
+Delayed::Job
+============
+[![Gem Version](https://badge.fury.io/rb/delayed_job.png)][gem]
+[![Build Status](https://secure.travis-ci.org/collectiveidea/delayed_job.png?branch=master)][travis]
+[![Dependency Status](https://gemnasium.com/collectiveidea/delayed_job.png?travis)][gemnasium]
+[![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
+[gem]: https://rubygems.org/gems/delayed_job
+[travis]: http://travis-ci.org/collectiveidea/delayed_job
+[gemnasium]: https://gemnasium.com/collectiveidea/delayed_job
+[codeclimate]: https://codeclimate.com/github/collectiveidea/delayed_job
+
+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. Amongst those tasks are:
* sending massive newsletters
* image resizing
@@ -12,61 +23,57 @@ It is a direct extraction from Shopify where the job table is responsible for a
* batch imports
* spam checks
-"Follow us on Twitter":https://twitter.com/delayedjob to get updates and notices about new releases.
+[Follow us on Twitter][twitter] to get updates and notices about new releases.
-h2. Installation
+[twitter]: https://twitter.com/delayedjob
-delayed_job 3.0.0 only supports Rails 3.0+. See the "2.0 branch":https://github.com/collectiveidea/delayed_job/tree/v2.0 for Rails 2.
+Installation
+============
+delayed_job 3.0.0 only supports Rails 3.0+. See the [2.0
+branch](https://github.com/collectiveidea/delayed_job/tree/v2.0) for Rails 2.
-delayed_job supports multiple backends for storing the job queue. "See the wiki for other backends":http://wiki.github.com/collectiveidea/delayed_job/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).
-If you plan to use delayed_job with Active Record, add @delayed_job_active_record@ to your @Gemfile@.
+If you plan to use delayed_job with Active Record, add `delayed_job_active_record` to your `Gemfile`.
-<pre>
-gem 'delayed_job_active_record'
-</pre>
+ gem 'delayed_job_active_record'
-If you plan to use delayed_job with Mongoid, add @delayed_job_mongoid@ to your @Gemfile@.
+If you plan to use delayed_job with Mongoid, add `delayed_job_mongoid` to your `Gemfile`.
-<pre>
-gem 'delayed_job_mongoid'
-</pre>
+ gem 'delayed_job_mongoid'
-Run @bundle install@ to install the backend and delayed_job gems.
+Run `bundle install` to install the backend and delayed_job gems.
-The Active Record backend requires a jobs table. You can create that table by running the following command:
+The Active Record backend requires a jobs table. You can create that table by
+running the following command:
-<pre>
-$ rails generate delayed_job:active_record
-$ rake db:migrate
-</pre>
-
-h3. Upgrading from 2.x to 3.0.0 on Active Record
+ rails generate delayed_job:active_record
+ rake db:migrate
+Upgrading from 2.x to 3.0.0 on Active Record
+============================================
Delayed Job 3.0.0 introduces a new column to the delayed_jobs table.
If you're upgrading from Delayed Job 2.x, run the upgrade generator to create a migration to add the column.
-<pre>
-$ rails generate delayed_job:upgrade
-$ rake db:migrate
-</pre>
+ rails generate delayed_job:upgrade
+ rake db:migrate
-h2. Queuing Jobs
+Queuing Jobs
+============
+Call `.delay.method(params)` on any object and it will be processed in the background.
-Call @.delay.method(params)@ on any object and it will be processed in the background.
+ # without delayed_job
+ @user.activate!(@device)
-<pre>
-# without delayed_job
-@user.activate!(@device)
+ # with delayed_job
+ @user.delay.activate!(@device)
-# with delayed_job
-@user.delay.activate!(@device)
-</pre>
-
-If a method should always be run in the background, you can call @#handle_asynchronously@ after the method declaration:
+If a method should always be run in the background, you can call
+`#handle_asynchronously` after the method declaration:
-<pre>
+```ruby
class Device
def deliver
# long running method
@@ -76,11 +83,13 @@ end
device = Device.new
device.deliver
-</pre>
+```
-handle_asynchronously can take as options anything you can pass to delay. In addition, the values can be Proc objects allowing call time evaluation of the value. For some examples:
+handle_asynchronously can take as options anything you can pass to delay. In
+addition, the values can be Proc objects allowing call time evaluation of the
+value. For some examples:
-<pre>
+```ruby
class LongTasks
def send_mailer
# Some other code
@@ -109,86 +118,91 @@ class LongTasks
end
handle_asynchronously :call_an_instance_method, :priority => Proc.new {|i| i.how_important }
end
-</pre>
-
-h3. Rails 3 Mailers
+```
+Rails 3 Mailers
+===============
Due to how mailers are implemented in Rails 3, we had to do a little work around to get delayed_job to work.
-<pre>
+```ruby
# without delayed_job
Notifier.signup(@user).deliver
# with delayed_job
Notifier.delay.signup(@user)
-</pre>
+```
-Remove the @.deliver@ method to make it work. It's not ideal, but it's the best we could do for now.
+Remove the `.deliver` method to make it work. It's not ideal, but it's the best
+we could do for now.
-h3. Named Queues
+Named Queues
+============
+DJ 3 introduces Resque-style named queues while still retaining DJ-style
+priority. The goal is to provide a system for grouping tasks to be worked by
+separate pools of workers, which may be scaled and controlled individually.
-DJ 3 introduces Resque-style named queues while still retaining DJ-style priority. The goal is to provide a system for grouping tasks to be worked by separate pools of workers, which may be scaled and controlled individually.
+Jobs can be assigned to a queue by setting the `queue` option:
-Jobs can be assigned to a queue by setting the @queue@ option:
-
-<pre>object.delay(:queue => 'tracking').method
+```ruby
+object.delay(:queue => 'tracking').method
Delayed::Job.enqueue job, :queue => 'tracking'
handle_asynchronously :tweet_later, :queue => 'tweets'
-</pre>
-
-h2. Running Jobs
+```
-@script/delayed_job@ can be used to manage a background process which will start working off jobs.
+Running Jobs
+============
+`script/delayed_job` can be used to manage a background process which will
+start working off jobs.
-To do so, add @gem "daemons"@ to your @Gemfile@ and make sure you've run `rails generate delayed_job`.
+To do so, add `gem "daemons"` to your `Gemfile` and make sure you've run `rails
+generate delayed_job`.
You can then do the following:
-<pre>
-$ RAILS_ENV=production script/delayed_job start
-$ RAILS_ENV=production script/delayed_job stop
+ RAILS_ENV=production script/delayed_job start
+ RAILS_ENV=production script/delayed_job stop
-# Runs two workers in separate processes.
-$ RAILS_ENV=production script/delayed_job -n 2 start
-$ RAILS_ENV=production script/delayed_job stop
+ # Runs two workers in separate processes.
+ RAILS_ENV=production script/delayed_job -n 2 start
+ RAILS_ENV=production script/delayed_job stop
-# Set the --queue or --queues option to work from a particular queue.
-$ RAILS_ENV=production script/delayed_job --queue=tracking start
-$ RAILS_ENV=production script/delayed_job --queues=mailers,tasks start
-</pre>
+ # Set the --queue or --queues option to work from a particular queue.
+ RAILS_ENV=production script/delayed_job --queue=tracking start
+ RAILS_ENV=production script/delayed_job --queues=mailers,tasks start
-Workers can be running on any computer, as long as they have access to the database and their clock is in sync. Keep in mind that each worker will check the database at least every 5 seconds.
+Workers can be running on any computer, as long as they have access to the
+database and their clock is in sync. Keep in mind that each worker will check
+the database at least every 5 seconds.
-You can also invoke @rake jobs:work@ which will start working off jobs. You can cancel the rake task with @CTRL-C@.
+You can also invoke `rake jobs:work` which will start working off jobs. You can
+cancel the rake task with `CTRL-C`.
-Work off queues by setting the @QUEUE@ or @QUEUES@ environment variable.
+Work off queues by setting the `QUEUE` or `QUEUES` environment variable.
-<pre>
-QUEUE=tracking rake jobs:work
-QUEUES=mailers,tasks rake jobs:work
-</pre>
-
-h2. Custom Jobs
+ QUEUE=tracking rake jobs:work
+ QUEUES=mailers,tasks rake jobs:work
+Custom Jobs
+===========
Jobs are simple ruby objects with a method called perform. Any object which responds to perform can be stuffed into the jobs table. Job objects are serialized to yaml so that they can later be resurrected by the job runner.
-<pre>
+```ruby
class NewsletterJob < Struct.new(:text, :emails)
def perform
emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }
end
end
Delayed::Job.enqueue NewsletterJob.new('lorem ipsum...', Customers.find(:all).collect(&:email))
-</pre>
-
-h2. Hooks
+```
+Hooks
+=====
You can define hooks on your job that will be called at different stages in the process:
-<pre>
+```ruby
class ParanoidNewsletterJob < NewsletterJob
def enqueue(job)
record_stat 'newsletter_job/enqueue'
@@ -218,13 +232,13 @@ class ParanoidNewsletterJob < NewsletterJob
page_sysadmin_in_the_middle_of_the_night
end
end
-</pre>
-
-h2. Gory Details
+```
+Gory Details
+============
The library revolves around a delayed_jobs table which looks as follows:
-<pre>
+```ruby
create_table :delayed_jobs, :force => true do |table|
table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
@@ -237,7 +251,7 @@ create_table :delayed_jobs, :force => true do |table|
table.string :queue # The name of the queue this job is in
table.timestamps
end
-</pre>
+```
On failure, the job is scheduled again in 5 seconds + N ** 4, where N is the number of retries.
@@ -258,20 +272,20 @@ It is possible to disable delayed jobs for testing purposes. Set Delayed::Worker
Here is an example of changing job parameters in Rails:
-<pre>
+```ruby
# config/initializers/delayed_job_config.rb
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 60
Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = 5.minutes
Delayed::Worker.read_ahead = 10
Delayed::Worker.delay_jobs = !Rails.env.test?
-</pre>
-
-h3. Cleaning up
-
-You can invoke @rake jobs:clear@ to delete all jobs in the queue.
+```
-h2. Mailing List
+Cleaning up
+===========
+You can invoke `rake jobs:clear` to delete all jobs in the queue.
-Join us on the "mailing list":http://groups.google.com/group/delayed_job
+Mailing List
+============
+Join us on the [mailing list](http://groups.google.com/group/delayed_job)
View
39 delayed_job.gemspec
@@ -1,28 +1,17 @@
# -*- encoding: utf-8 -*-
-Gem::Specification.new do |s|
- s.name = 'delayed_job'
- s.version = '3.0.4'
- s.authors = ["Matt Griffin", "Brian Ryckbost", "Steve Richert", "Chris Gaffney", "Brandon Keepers", "Tobias L\303\274tke", "David Genord II"]
- 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.
-
-This gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job)."
- s.email = ['brian@collectiveidea.com']
- s.extra_rdoc_files = 'README.textile'
- s.files = Dir.glob('{contrib,lib,recipes,spec}/**/*') +
- %w(MIT-LICENSE README.textile)
- s.homepage = 'http://github.com/collectiveidea/delayed_job'
- s.licenses = ["MIT"]
- s.rdoc_options = ["--main", "README.textile", "--inline-source", "--line-numbers"]
- s.require_paths = ["lib"]
- s.test_files = Dir.glob('spec/**/*')
-
- s.add_runtime_dependency 'activesupport', '~> 3.0'
-
- s.add_development_dependency 'activerecord', '~> 3.0'
- s.add_development_dependency 'actionmailer', '~> 3.0'
- s.add_development_dependency 'rspec', '~> 2.11'
- s.add_development_dependency 'rake'
- s.add_development_dependency 'simplecov'
+Gem::Specification.new do |spec|
+ spec.add_dependency 'activesupport', '~> 3.0'
+ spec.authors = ["Brandon Keepers", "Brian Ryckbost", "Chris Gaffney", "David Genord II", "Erik Michaels-Ober", "Matt Griffin", "Steve Richert", "Tobias Lütke"]
+ spec.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."
+ spec.email = ['brian@collectiveidea.com']
+ spec.files = %w(CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile delayed_job.gemspec)
+ spec.files += Dir.glob('{contrib,lib,recipes,spec}/**/*')
+ spec.homepage = 'http://github.com/collectiveidea/delayed_job'
+ spec.licenses = ['MIT']
+ spec.name = 'delayed_job'
+ spec.require_paths = ['lib']
+ spec.summary = 'Database-backed asynchronous priority queue system -- Extracted from Shopify'
+ spec.test_files = Dir.glob('spec/**/*')
+ spec.version = '3.0.4'
end

0 comments on commit 5b5f971

Please sign in to comment.
Something went wrong with that request. Please try again.