Add wrap_in_app_executor in a few necessary places #673
+16
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Process#registerand#degisterfor the supervisor to start up properly.RecurringSchedule#reload_tasksresolves all the records immediately to avoid deferred resolution outside the executor block.Supervisor#handle_claimed_jobs_bywraps its code in the executor.A second attempt at #655 without causing the issues from #670
This PR unfortunately doesn't add any tests; I tried and failed to come up with a strategy that would check all database code was wrapped properly that didn't involve massive restructuring of tests. If you have any good ideas on how to do that, please let me know.
(As an aside, the reason for this PR and #655 is that I'm working on multi-tenant support for Solid Queue, using Active Record Tenanted which relies on Rails' sharding features. I'd like to use the app executor's run/complete callbacks to set/unset the shard.)