Commit Graph

239 Commits

Author SHA1 Message Date
yuuji.yaginuma
6a8e7fd8d8 fix link to resque [ci skip]
`1-x-stable` branch does not exist, `master` is 1.x branch.
Ref: http://words.steveklabnik.com/rescuing-resque-again
2016-09-20 08:56:05 +09:00
yuuji.yaginuma
0b2197774c use descendants to get class that inherited ActiveJob::Base
`subclasses` get only child classes.
Therefore, if create a job common parent class as `ApplicationJob`,
inherited class does not get properly.
2016-09-05 09:21:10 +09:00
Xavier Noria
bb1ecdcc67 fixes remaining RuboCop issues [Vipul A M, Xavier Noria] 2016-09-01 23:41:49 +02:00
Rafael Mendonça França
0510208dd1
Add load hooks to all tests classes
Usually users extends tests classes doing something like:

    ActionView::TestCase.include MyCustomTestHelpers

This is bad because it will load the ActionView::TestCase right aways
and this will load ActionController::Base making its on_load hooks to
execute early than it should.

One way to fix this is using the on_load hooks of the components like:

    ActiveSupport.on_load(:action_view) do
      ActionView::TestCase.include MyCustomTestHelpers
    end

The problem with this approach is that the test extension will be only
load when ActionView::Base is loaded and this may happen too late in the
test.

To fix this we are adding hooks to people extend the test classes that
will be loaded exactly when the test classes are needed.
2016-08-25 04:22:48 -03:00
Rafael Mendonça França
7f4b16ed83
Merge pull request #26205 from pedaling-corp/fix/active-job-resque
Add @queue variable to JobWrapper
2016-08-23 00:39:39 -03:00
yuuji.yaginuma
88f9a1540a correct exception class in retry_on example [ci skip]
If the deadlock has occurred `ActiveRecord::Deadlocked` will raise.
Ref: #25107, #26059
2016-08-20 17:21:14 +09:00
InJung Chung
9f6461a28c Added instance variable @queue to JobWrapper.
This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method,
so we can use `#enqueue_delayed_selection`, `#remove_delayed` method in resque-scheduler smoothly.
2016-08-19 17:10:27 +09:00
David Heinemeier Hansson
a1e4c197cb Yield the job instance so you have access to things like job.arguments on the custom logic after retries fail 2016-08-16 16:01:59 -07:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
a9dc45459a code gardening: removes redundant selfs
A few have been left for aesthetic reasons, but have made a pass
and removed most of them.

Note that if the method `foo` returns an array, `foo << 1`
is a regular push, nothing to do with assignments, so
no self required.
2016-08-08 01:12:38 +02:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
93c9534c98 applies new string literal convention in activejob/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:40:07 +02:00
David Heinemeier Hansson
01a69e27a4 Offer invitations to use retry_on/discard_on for common cases 2016-08-04 14:57:10 -07:00
David Heinemeier Hansson
4f5a9890b7 Guard against jobs that were persisted before we started counting executions by zeroing out nil counters 2016-08-03 14:30:39 -07:00
David Heinemeier Hansson
7efd77fae5 Fix tests against ActiveSupport::Durations 2016-08-02 14:27:01 -07:00
David Heinemeier Hansson
111227c0df Please Rubocup 2016-08-02 12:28:16 -07:00
David Heinemeier Hansson
9d8d4ee05e Allow for custom handling of exceptions that persist beyond the retry attempts 2016-08-01 16:51:11 -07:00
David Heinemeier Hansson
0be5d5d4c4 Add exponentially_longer and custom wait algorithms 2016-08-01 16:44:29 -07:00
David Heinemeier Hansson
a4fc7dc957 Executions counting is not a serialization concern
Let’s do it when we actually execute instead. Then the tests dealing
with comparable serializations won’t fail either!
2016-08-01 16:02:50 -07:00
David Heinemeier Hansson
779148d390 Reraise instead of swallow exceptions that occur beyond the retry attempts 2016-07-29 15:15:31 -07:00
David Heinemeier Hansson
f931290e58 Proper logging when we bail on retrying after X attempts 2016-07-29 15:07:50 -07:00
David Heinemeier Hansson
8457e5eb1d Allow retries to happen with different priority and queue 2016-07-29 14:23:39 -07:00
David Heinemeier Hansson
b00214d214 Require time extension for 3.seconds default 2016-07-29 14:21:02 -07:00
David Heinemeier Hansson
504a7d0530 Mention defaults 2016-07-29 14:20:29 -07:00
David Heinemeier Hansson
4139b14492 Satisfy pedantic rubocop whitespace detection 2016-07-29 13:59:40 -07:00
David Heinemeier Hansson
5ce59f456f Remove needless require 2016-07-29 13:57:37 -07:00
David Heinemeier Hansson
8b5c04e423 Add retry_on/discard_on for better exception handling 2016-07-29 13:54:55 -07:00
Azzurrio
80e825915c Fix accessing provider_job_id inside active jobs for sidekiq adapter 2016-07-28 04:12:15 +02:00
Jean Boussier
be491ecec2 Fix jobs overriding AJ::Base#logger 2016-06-17 13:04:17 -04:00
Steve Lounsbury
38c187b0cc Provide the ability to override the queue adapter used by jobs under
test.

This PR adds a method called `queue_adapter_for_test` to
`ActiveJob::TestHelper`. This method is expected to provide the queue
adapter to be used for jobs under test. It maintains the current
behaviour by defaulting to an instance of
`ActiveJob::QueueAdapter::TestAdapter`. Tests that include
`ActiveJob::TestHelper` or extend from `ActiveJob::TestCase` can provide
a custom queue adapter by overriding `queue_adapter_for_test` in their
class.
2016-06-11 15:18:52 -04:00
Jake Worth
ffb6ab4fe1 Fix typo, of of -> of [ci skip] 2016-06-09 16:23:58 -05:00
Tim Wade
ad9882369a
[ci skip] Reword doc for around_enqueue callback
Taken literally, the documentation suggests that the callback gets
called twice (before and after enqueueing). By wording it similarly to
that of around_perform this confusion is avoided.
2016-05-27 15:39:30 -07:00
Jeremy Daer
89e2f7e722
Support for unified Integer class in Ruby 2.4+
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005

* Forward compat with new unified Integer class in Ruby 2.4+.
* Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3.
* Drops needless Fixnum distinction in docs, preferring Integer.
2016-05-18 21:58:51 -07:00
Jeremy Daer
e35b98e6f5
Action Mailer: Declarative exception handling with rescue_from.
Follows the same pattern as controllers and jobs. Exceptions raised in
delivery jobs (enqueued by `#deliver_later`) are also delegated to the
mailer's rescue_from handlers, so you can handle the DeserializationError
raised by delivery jobs:

```ruby
class MyMailer < ApplicationMailer
  rescue_from ActiveJob::DeserializationError do
    …
  end
```

ActiveSupport::Rescuable polish:
* Add the `rescue_with_handler` class method so exceptions may be
  handled at the class level without requiring an instance.
* Rationalize `exception.cause` handling. If no handler matches the
  exception, fall back to the handler that matches its cause.
* Handle exceptions raised elsewhere. Pass `object: …` to execute
  the `rescue_from` handler (e.g. a method call or a block to
  instance_exec) against a different object. Defaults to `self`.
2016-05-15 18:44:16 -07:00
Rafael Mendonça França
8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Rafael Mendonça França
fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
eileencodes
f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Graeme Boy
6e27481dc7 Fix typo in ActiveJob #retry_job doc 2016-04-23 17:23:19 -07:00
Mohit Natoo
23f472ae7c - [ci skip] Active Job Async doesn't support to Async feature as per it's definition.
- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.

- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.

- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.

- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.
2016-04-22 15:37:20 +05:30
Eileen M. Uchitelle
e88d63e6f7 Merge pull request #24165 from y-yagi/generate_application_job_when_not_exist
generate ApplicationJob if it does not already exist
2016-04-09 09:46:37 -04:00
yuuji.yaginuma
87824ab583 update assert_no_performed_jobs doc to use assert_no_performed_jobs method [ci skip] 2016-03-30 08:12:49 +09:00
yuuji.yaginuma
9a9fc01af0 generate ApplicationJob if it does not already exist
ActiveJob jobs now inherit from ApplicationJob by default.
However, when updating to Rails 5 from the old Rails,
since there is a possibility that ApplicationJob does not exist.
2016-03-25 13:21:37 +09: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
Matthew Draper
5bdeb9bfd7 Use AS::Reloader to support reloading in ActiveJob 2016-03-02 02:14:54 +10:30
Jeremy Daer
a66780bfff Active Job: smaller footprint for the dev/test async adapter
Use one shared worker pool for all queues with 0-#CPU workers rather
than separate pools per queue with 2-10*#CPU workers each.
2016-02-29 15:58:26 -07:00
Rafael Mendonça França
116581be91 Do not define methods in the included block
Instance methods can be defined in the module itself
2016-02-24 13:37:32 -03:00
eileencodes
826420b5fc Prep release for Rails 5 beta3 2016-02-24 10:27:02 -05:00
Abhishek Jain
9a2ca9cf69 [ci skip] Fix enqueuing spelling to maintain consistency 2016-02-12 23:49:08 +05:30