ActiveJob: queue_adapter can be inherited#16992
Conversation
a91699a to
3092006
Compare
b0f3a44 to
4275f40
Compare
4275f40 to
208c9b9
Compare
There was a problem hiding this comment.
We have 4 lines like this. Maybe let's return it from a method like job_hash(job) ?
There was a problem hiding this comment.
Actually even more natural would be job.to_hash
208c9b9 to
22118ce
Compare
|
The test adapter was made like this so we can run tests in parallel. @seuros you worked on this |
There was a problem hiding this comment.
Please rename _queue_adapter to something else _queue_adapter_class or even queue_adapter_class to be more clear
There was a problem hiding this comment.
It's not always a class, though. It may be a callable. I'll change the name to reflect that.
|
Here's the PR when we switch the test adapter to instance methods #16724 (diff) |
22118ce to
1d5b389
Compare
There was a problem hiding this comment.
We don't need these teardowns. The test adapter sould to allow parallel test instantiated for every test
There was a problem hiding this comment.
Not anymore, it's a singleton now. See existing discussion in this PR.
d933fb3 to
6f851ec
Compare
|
Ok. So ... as discussed the ability to pass a proc to queue_adapter is still under discussion so I suggest to leave this PR with the initial scope of being able to override sub-jobs adapters and start a new PR with the proc thing. |
|
Also you need to rebase before we're ready to merge |
|
I meant to rebase so you can squash your commits |
|
Then you should split them into multiple PRs. |
|
No need to squash or split it into multiple PRs. Looks good to me 👍 |
|
I'd keep |
|
I was erroneously ccd. the mail should have gone to @tamird i think. On 08 Oct 2014, at 09:02, Cristian Bica notifications@github.com wrote:
|
6f851ec to
c80f403
Compare
There was a problem hiding this comment.
Every ActiveJob::Base subclass will respond to :queue_adapter since it's a singleton method on Base
There was a problem hiding this comment.
derp, you're right. fixed
9515e8a to
cbaa77d
Compare
There was a problem hiding this comment.
Since class attributes no longer inherit from superclass once they're written, assigning #queue_adapter on classes the didn't have it explicitly set will leak side effects between test cases (since changing a superclass attr won't be inherited by its subclass afterward)
fabae1a to
2a30528
Compare
There was a problem hiding this comment.
Prefer to use the public-API reader?
This allows different `queue_adapters` to be used in each `ActiveJob` class heirarchy. Previously, all subclasses used a single global queue adapter.
2a30528 to
1f8558f
Compare
ActiveJob: queue_adapter can be inherited
|
❤️ took a few months to get this merged :) |
|
👍 |
|
I'm not seeing this feature being mentioned in the Basics guide. Or we have an Advanced guide somewhere that I don't know :)? I think this is cool and deserves a mention. Should I submit a PR or has anyone worked on this already? |
|
👍 |
|
Is code merged in such that it's possible to have different queue adapters for different jobs? (and if so beginning in what Rails version) I got here following a trail of links between issues and PRs here and in ActiveJob. And the disussion and statuses here make me think this is now possible. But I have no idea how to do it! If I'm on the right track, could anyone post an example here? If I get an example, I will try to play with it and understand it and do a doc PR demo'ing it in the right place. (If it's already in the docs but I just haven't found it, would very much appreciate if you wanted to point me there!). |
|
Nevermind, just found it in the guide! "You can also configure your backend on a per job basis." Okay! Great! |
|
does anyone have a "patch" i can use in my rails 4.2 app to get this to work? |
Rails 5+ allows to set queue adapter per job class rails/rails#16992
Rails 5+ allows to set queue adapter per job class rails/rails#16992
Rails 5+ allows to set queue adapter per job class rails/rails#16992
@cristianbica this is #16968