Skip to content

Conversation

@brendon
Copy link
Contributor

@brendon brendon commented Mar 7, 2025

Sometimes it's handy to have provider_job_id available within perform. The Sidekiq adapter does it and Rails allows for it:

https://github.com/rails/rails/blob/aa2bfad1a137c9add1b35de118b391494e13ca06/activejob/lib/active_job/core.rb#L35

So far I'm not sure how to test this and the suite doesn't appear to go so far as testing the execution of jobs or at least what is available within perform(). Some guidance would be much appreciated :)

Closes #514

@brendon
Copy link
Contributor Author

brendon commented Mar 7, 2025

In my quick testing on my local app with this branch it still doesn't seem to work, so please hold off merging :)

@brendon
Copy link
Contributor Author

brendon commented Mar 7, 2025

Ok, now it's working. My mistake was passing a symbol instead of a string. A test would still be good though.

@rosa
Copy link
Member

rosa commented Mar 7, 2025

Thank you @brendon!

So far I'm not sure how to test this and the suite doesn't appear to go so far as testing the execution of jobs or at least what is available within perform(). Some guidance would be much appreciated :)

Good question! I think you could try adding a new test job (to test/dummy/app/jobs) that does something with the provider_job_id, in a way you can check it later (perhaps in a similar way to AddToBufferJob. I'd probably include this test in test/models/solid_queue/claimed_execution_test.rb.

@brendon
Copy link
Contributor Author

brendon commented Mar 8, 2025

Thanks for the tip. I've added a passing test. I think this one is ready to go.

I'm not 100% sure that's the best point to inject into the arguments but I couldn't find a better spot.

@brendon
Copy link
Contributor Author

brendon commented Mar 12, 2025

Hi @rosa, did you need anything more from me to merge this PR? :)

@rosa
Copy link
Member

rosa commented Mar 14, 2025

Hey @brendon, sorry for the delay! I think this is ready, thank you so much! 🙏

@rosa rosa merged commit 2fe1b3e into rails:main Mar 14, 2025
34 checks passed
@brendon
Copy link
Contributor Author

brendon commented Mar 14, 2025

No worries :) Thank you too.

If it’s not too much trouble would you be able to release a new gem version in the next little while? :)

@rosa
Copy link
Member

rosa commented Mar 17, 2025

@brendon yes! Going to release a new version today.

@brendon
Copy link
Contributor Author

brendon commented Mar 17, 2025

Nice! :D Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessing the job from within the perform method

2 participants