Commit Graph

21 Commits

Author SHA1 Message Date
Rafael Mendonça França
798289699d
Remove deprecated support to set numeric values to scheduled_at attribute 2023-11-22 22:13:06 +00:00
Ben Sheldon [he/him]
c919b474a7
Set, serialize, and deserialize Active Job scheduled_at as Time; deserialize enqueued_at as Time; deprecate setting scheduled_at= with numeric/epoch
Co-authored-by: Adam Pahlevi <adam.pahlevi@gmail.com>
2023-09-26 17:01:41 -07:00
Jeremy Daer
8d9d8013ca Preserve job.enqueued_at timestamp precision
* Allows instrumenters to more accurately deduce queue wait time
* Retains IS08601 compatibility

References #39698
2022-07-12 18:13:16 -07:00
Jonathan Hefner
056b252010 Fix random CI fail due to auto-updating timestamp
Example failure: https://buildkite.com/rails/rails/builds/68074#0fe7ca54-fcce-4a47-85db-a784275c8f51/1115-1125

Each time a job is serialized, `enqueued_at` is updated.  Thus, separate
serializations of the same job can have different `enqueued_at`
timestamps if the serializations do not occur within the same second.
2020-04-06 23:31:29 -05:00
Cory Gwin @gwincr11
31021c780f
Adding enque time tracking and logging
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.
2019-02-13 19:20:41 -05:00
Rafael Mendonça França
5b9cd1a579
Make sure that when serialing an just deserialized job arguments are there
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.
2018-05-01 13:33:50 -04:00
Andrew White
a9d1167b1f Add support for timezones to Active Job
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.
2018-02-22 14:14:42 +00:00
Koichi ITO
aa28c5ca65 [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
Kir Shatrov
14ece5e429 Use frozen-string-literal in ActiveJob 2017-07-09 20:50:52 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
utilum
b58d73fc57 ActiveJob::Core#serialize stores provider_job_id (fixes #26581). 2017-06-27 07:08:55 +02:00
Xavier Noria
bde6547bb6 applies new string literal convention in activejob/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:41:18 +02:00
Mike Perham
8c98186742 Add JSON round trip verification testcase 2016-03-09 09:28:16 -08:00
Mike Perham
702ef37767 Job payload should be symmetric across JSON dump/load
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.
2016-03-09 08:56:21 -08:00
Kasper Timm Hansen
a7fcb0e50a Add missing HelloJob require.
This way JobSerializationTest runs in isolation without errors.
2015-08-05 21:55:42 +02:00
Johannes Opper
3860e6b2bf Fixes #20799
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.
2015-08-04 00:38:18 +02:00
Cristian Bica
1e237b4e44 Active Job refactoring 2014-09-03 23:01:46 +03:00
Abdelkader Boudih
931cfc4079 [ActiveJob] Fix tests for sucker_punch 2014-08-17 23:10:45 +00:00
Cristian Bica
788aee5acf Moved AR testing from using global variable to thread variable 2014-08-16 00:02:06 +03:00
Abdelkader Boudih
a75f085941 Add 'activejob/' from commit '14f74a8331f94150dfee653224de8fc837797709'
git-subtree-dir: activejob
git-subtree-mainline: b45b99894a60eda434abec94d133a1cfd8de2dda
git-subtree-split: 14f74a8331f94150dfee653224de8fc837797709
2014-08-12 09:17:19 +00:00