Skip to content
This repository

Updated README to match current code #49

Open
wants to merge 1 commit into from

1 participant

Turadg Aleahmad
Turadg Aleahmad

The README refers to send_later which no longer works. I updated the Usage section for how it works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 31, 2011
Turadg Aleahmad turadg Updated README to match current code fad14fe
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 17 additions and 11 deletions. Show diff stats Hide diff stats

  1. +17 11 README.textile
28 README.textile
Source Rendered
@@ -62,8 +62,19 @@ Note: If your error messages are long, consider changing last_error field to a :
62 62
63 63 h2. Usage
64 64
65   -Jobs are simple ruby objects with a method called perform. Any object which responds to perform can be stuffed into the jobs table.
66   -Job objects are serialized to yaml so that they can later be resurrected by the job runner.
  65 +If you are delaying a single method call, you can queue up that call simply be prefixing it with @delay@. (@send_later@ is deprecated) E.g.,
  66 +
  67 +<pre><code>
  68 + UserMailer.send_welcome_email(user)
  69 + BatchImporter.new(Shop.find(1)).import_massive_csv(massive_csv)
  70 +</code></pre>
  71 +becomes
  72 +<pre><code>
  73 + serMailer.delay.send_welcome_email(user)
  74 + BatchImporter.new(Shop.find(1)).delay.import_massive_csv(massive_csv)
  75 +</code></pre>
  76 +
  77 +You can make more complicated jobs by creating a simple Ruby object 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. E.g.,
67 78
68 79 <pre><code>
69 80 class NewsletterJob < Struct.new(:text, :emails)
@@ -75,14 +86,7 @@ Job objects are serialized to yaml so that they can later be resurrected by the
75 86 Delayed::Job.enqueue NewsletterJob.new('lorem ipsum...', Customers.find(:all).collect(&:email))
76 87 </code></pre>
77 88
78   -There is also a second way to get jobs in the queue: send_later.
79   -
80   -<pre><code>
81   - BatchImporter.new(Shop.find(1)).send_later(:import_massive_csv, massive_csv)
82   -</code></pre>
83   -
84   -This will simply create a @Delayed::PerformableMethod@ job in the jobs table which serializes all the parameters you pass to it. There are some special smarts for active record objects
85   -which are stored as their text representation and loaded from the database fresh when the job is actually run later.
  89 +When you use the @delay@ method, it simply creates a @Delayed::PerformableMethod@ job in the jobs table which serializes all the parameters you pass to it. There are some special smarts for active record objects which are stored as their text representation and loaded from the database fresh when the job is actually run later.
86 90
87 91
88 92 h2. Running the jobs
@@ -106,7 +110,7 @@ run multiple workers on per computer, but you must give each one a unique name:
106 110 worker = Delayed::Worker.new
107 111 worker.name = 'worker-' + n.to_s
108 112 worker.start
109   - end
  113 + end
110 114 </code></pre>
111 115
112 116 Keep in mind that each worker will check the database at least every 5 seconds.
@@ -119,6 +123,8 @@ You can invoke @rake jobs:clear@ to delete all jobs in the queue.
119 123
120 124 h3. Changes
121 125
  126 +* 2.0: TO WRITE
  127 +
122 128 * 1.7.0: Added failed_at column which can optionally be set after a certain amount of failed job attempts. By default failed job attempts are destroyed after about a month.
123 129
124 130 * 1.6.0: Renamed locked_until to locked_at. We now store when we start a given job instead of how long it will be locked by the worker. This allows us to get a reading on how long a job took to execute.

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.