aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_job/enqueuing.rb
diff options
context:
space:
mode:
authorCristian Bica <cristian.bica@gmail.com>2014-05-31 02:19:30 +0300
committerCristian Bica <cristian.bica@gmail.com>2014-06-12 14:01:40 +0300
commit243d74eb30464dc95cb07c0bd14cc086f9cd7022 (patch)
tree34301629fe446bd394b5b0e32cf66f949afe0d53 /lib/active_job/enqueuing.rb
parent4ac8dc21440ecdea9c0452a0c12e8bcc487bc776 (diff)
downloadrails-243d74eb30464dc95cb07c0bd14cc086f9cd7022.tar.gz
rails-243d74eb30464dc95cb07c0bd14cc086f9cd7022.tar.bz2
rails-243d74eb30464dc95cb07c0bd14cc086f9cd7022.zip
Persist job_id
Diffstat (limited to 'lib/active_job/enqueuing.rb')
-rw-r--r--lib/active_job/enqueuing.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/active_job/enqueuing.rb b/lib/active_job/enqueuing.rb
index 0f094fb624..e3ac11ba97 100644
--- a/lib/active_job/enqueuing.rb
+++ b/lib/active_job/enqueuing.rb
@@ -3,19 +3,19 @@ require 'active_job/arguments'
module ActiveJob
module Enqueuing
extend ActiveSupport::Concern
-
+
module ClassMethods
# Push a job onto the queue. The arguments must be legal JSON types
# (string, int, float, nil, true, false, hash or array) or
# ActiveModel::GlobalIdentication instances. Arbitrary Ruby objects
# are not supported.
#
- # Returns an instance of the job class queued with args available in
+ # Returns an instance of the job class queued with args available in
# Job#arguments.
def enqueue(*args)
new(args).tap do |job|
job.run_callbacks :enqueue do
- queue_adapter.enqueue self, *Arguments.serialize(args)
+ queue_adapter.enqueue self, job.job_id, *Arguments.serialize(args)
end
end
end
@@ -24,7 +24,7 @@ module ActiveJob
#
# enqueue_in(1.week, "mike")
#
- # Returns an instance of the job class queued with args available in
+ # Returns an instance of the job class queued with args available in
# Job#arguments and the timestamp in Job#enqueue_at.
def enqueue_in(interval, *args)
enqueue_at interval.seconds.from_now, *args
@@ -34,19 +34,19 @@ module ActiveJob
#
# enqueue_at(Date.tomorrow.midnight, "mike")
#
- # Returns an instance of the job class queued with args available in
+ # Returns an instance of the job class queued with args available in
# Job#arguments and the timestamp in Job#enqueue_at.
def enqueue_at(timestamp, *args)
new(args).tap do |job|
job.enqueued_at = timestamp
job.run_callbacks :enqueue do
- queue_adapter.enqueue_at self, timestamp.to_f, *Arguments.serialize(args)
+ queue_adapter.enqueue_at self, timestamp.to_f, job.job_id, *Arguments.serialize(args)
end
end
end
end
-
+
included do
attr_accessor :arguments
attr_accessor :enqueued_at
@@ -55,11 +55,11 @@ module ActiveJob
def initialize(arguments = nil)
@arguments = arguments
end
-
+
def retry_now
self.class.enqueue *arguments
end
-
+
def retry_in(interval)
self.class.enqueue_in interval, *arguments
end