aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/core.rb
Commit message (Collapse)AuthorAgeFilesLines
* Make sure that when serialing an just deserialized job arguments are thereRafael Mendonça França2018-05-011-4/+16
| | | | | | | | | | | | | When a job was just deserialized `arguments` is `nil` and the serialized arguments are in the `@serialized_arguments` variable. If we try to serialize this job again the arguments are going to be `nil` instead of what was serialized. The test we had was not checking this case because it was deserializing the job in the same object that had the arguments. To fix this, when the `@serialized_arguments` are present we return it instead of the result of the `arguments` serialized.
* Add support for timezones to Active JobAndrew White2018-02-221-1/+6
| | | | | | Record what was the current timezone in effect when the job was enqueued and then restore when the job is executed in same way that the current locale is recorded and restored.
* Fix example code in ActiveJob::Core [ci skip]Yoshiyuki Hirano2017-12-051-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) It seems that it raise error on example code in `ActiveJob::Core`. Before: ```ruby class DeliverWebhookJob < ActiveJob::Base def serialize super.merge('attempt_number' => (@attempt_number || 0) + 1) end def deserialize(job_data) super @attempt_number = job_data['attempt_number'] end rescue_from(Timeout::Error) do |exception| raise exception if @attempt_number > 5 retry_job(wait: 10) end def perform raise Timeout::Error end end ``` Then it run `DeliverWebhookJob.perform_now` in `rails console`. And raise error: NoMethodError: undefined method `>' for nil:NilClass from /app/jobs/deliver_webhook_job.rb:12:in `block in <class:DeliverWebhookJob>' So I thought it's necessary to fix it. After: ```ruby class DeliverWebhookJob < ActiveJob::Base attr_writer :attempt_number def attempt_number @attempt_number ||= 0 end def serialize super.merge('attempt_number' => attempt_number + 1) end def deserialize(job_data) super self.attempt_number = job_data['attempt_number'] end rescue_from(Timeout::Error) do |exception| raise exception if attempt_number > 5 retry_job(wait: 10) end def perform raise Timeout::Error end end ``` Then it run `DeliverWebhookJob.perform_now` in `rails console`. And it does'nt raise error NoMethodError. 2) Use `Timeout::Error` instead of `TimeoutError` (`TimeoutError` is deprecated).
* [Active Job] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveJobKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* ActiveJob::Core#serialize stores provider_job_id (fixes #26581).utilum2017-06-271-0/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* applies new string literal convention in activejob/libXavier Noria2016-08-061-15/+15
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Executions counting is not a serialization concernDavid Heinemeier Hansson2016-08-011-1/+1
| | | | | Let’s do it when we actually execute instead. Then the tests dealing with comparable serializations won’t fail either!
* Add retry_on/discard_on for better exception handlingDavid Heinemeier Hansson2016-07-291-0/+6
|
* Fix accessing provider_job_id inside active jobs for sidekiq adapterAzzurrio2016-07-281-0/+1
|
* Add JSON round trip verification testcaseMike Perham2016-03-091-1/+1
|
* Job payload should be symmetric across JSON dump/loadMike Perham2016-03-091-1/+1
| | | Placing non-native JSON data types, like symbols, in the hash to serialize means that the deserialize method will return something different from what was serialized, a common bug and source of frustration for devs.
* Add job priorities to ActiveJobwvengen2015-09-171-0/+8
|
* Fixes #20799Johannes Opper2015-08-041-1/+6
| | | | | | | | | | | | | | | | | | | | | | When `#perform_later` is called the locale isn't stored on the queue, which results in a locale reset when the job is performed. An example of the problem: I18n.locale = 'de' HelloJob.perform_now # german message, correct but I18n.locale = 'de' HelloJob.perform_later # english message, incorrect This PR attaches the current I18n.locale to every job during the serialization process. It is then restored during deserialization and used to perform the job with the correct locale. It falls back to the default locale if no serialized locale is found in order to provide backward compatibility with previously stored jobs. It is not necessary to clear the queue for the update.
* Get provider_job_id from DelayedJobKevin Deisz2015-05-051-0/+3
| | | | | When queueing with DelayedJob, get the id of the job instance and report it back to ActiveJob as provider_job_id.
* Add initial doc for Core in AJ [ci skip]Zachary Scott2015-04-291-0/+2
|
* Tiny follow-up to #18260 [ci skip]Robin Dupret2014-12-311-3/+3
| | | | | | | Indent the list content by 4 spaces instead of 2 to match the other changelog files. Also wrap the lines around 80 chars. Finally update the documentation example with nit-picky things.
* ActiveJob: delegate full deserialization to classIsaac Seymour2014-12-301-4/+28
|
* Add documentation for class methods module included for AJ::Core usedZachary Scott2014-11-031-0/+2
| | | | for serialization and deserialization of jobs. [ci skip]
* Tiny documentation improvements [ci skip]Robin Dupret2014-10-311-5/+2
|
* [ci skip] fix typo in set examplesyuuji.yaginuma2014-09-271-2/+2
|
* [ci skip] AJ docs fixesAkshay Vishnoi2014-09-181-1/+1
| | | | | | | | 1. Indentation 2. Spaces issues 3. Spelling correction 4. Grammar correction 5. Add #:nodoc: to all internal classes
* Active Job refactoringCristian Bica2014-09-031-0/+89