aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/core.rb
Commit message (Collapse)AuthorAgeFilesLines
* [ci skip] activejob typo fix.alkesh262019-02-251-1/+1
|
* Adding enque time tracking and loggingCory Gwin @gwincr112019-02-131-1/+6
| | | | | | | | | | | | | | | Motivation: - Currently we have 2 seperate monkey patches in place for tracking enqueded time for 2 seperate workers. It seems that activejob could be a source of truth for how long an item has been enqued so that we can easily use it for consistent monitoring across workers/apps to ensure that jobs are running at an acceptable speed. Changes: - Add an enqueded at attribute and serilization tooling. - Add a method to get how long a job has been enqueded for. - Add a logging item to show how long a job was enqued prior to the perform method firing.
* Ensure 0 is always the default for the individual exception counters in ↵Rosa Gutierrez2019-01-081-1/+1
| | | | | | | | | | | ActiveJob Some adapters like Resque that use Redis, convert the Ruby hash with a default value, Hash.new(0), into a regular hash without a default value after serializing, storing and deserializing. This raises an error when we try to access a missing exception key. A simple solution is not to rely on the hash's default value, and provide a default as alternative when accessing it instead.
* Keep executions for each specific exception (#34352)Alberto Almagro2018-11-231-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Keep executions for each specific declaration Fixes #34337 ActiveJob used the global executions counter to control the number of times a job should be retried. The problem with this approach was that in case a job raised different exceptions during its executions they weren't retried the number of times defined by their `attemps` number. **Example:** Having the following job: ```ruby class BuggyJob < ActiveJob::Base retry_on CustomException, attemps: 3 retry_on OtherException, attempts: 3 end ``` If the job raised `CustomException` in the first two executions and then it raised `OtherException`, the job wasn't retried anymore because the global executions counter was already indicating 3 attempts. With this patch each `retry_on` declaration has its specific counter so that the first two executions that raise `CustomException` don't affect the retries count that future exceptions may have. * Revert "clarifies documentation around the attempts arugment to retry_on" This reverts commit 86aa8f8c5631f77ed9a208e5107003c01512133e.
* Change queueing to queuing in docs and comments [skip ci]jacobherrington2018-11-181-1/+1
| | | | | | | | | My spellchecker flagged this as an incorrect spelling, upon further research it appears to be a point of contention in English. Either way might work. After further examination queuing is much more common in the Rails codebase so making this change will serve to standardize the spelling.
* Remove unnecessary use of `included` in ActiveJob::CoreAlan Wu2018-10-051-21/+19
| | | | | Using `included` to define `attr_acessor` and `attr_writer` is causing these methods to not show up in the documentation.
* 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