Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract GoodJob::Capsule #861

Merged
merged 1 commit into from
Feb 28, 2023
Merged

Extract GoodJob::Capsule #861

merged 1 commit into from
Feb 28, 2023

Conversation

bensheldon
Copy link
Owner

Extracts the duplicated instantiation of Scheduler, Poller, CronManager, etc that existed in both the Async Adapter and CLI into a single object.

Observations and Risks

  • This creates a global GoodJob.capsule that holds the Scheduler (thread executor). It was previously easily possible to create multiple async Adapters, and thus end up with multiple Schedulers. This PR creates a better distinction and symmetry between the Adapter which enqueues, and the Capsule, which dequeues/executes. I think that subtly changes the meaning of the Adapters Async mode, but not a lot:
    • Old: Async Adapter executes in the same process
    • New: Async Adapter will enqueue and attempt to execute the job in an existing Capsule/Scheduler that may be running in the current process. (That’s a mouthful)
  • As always, Rails boot/startup has some risky async orchestration.
  • Where it's going: The future destination is having a stronger guarantee around the Process record: that the Process record must be present before jobs are executed, the Process record must be present until after the Schedulers are shut down, and Schedulers must not execute jobs if the Process record does not exist or is in a bad state. This makes it easier to get to Proposal: convert from session-based Advisory Locks to locked_at/locked_by columns #831. That also means that eventually “Process Record” will really be “Capsule (Process) Record” but that likely won’t be noticed

@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 24, 2023 14:49 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 24, 2023 15:40 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 24, 2023 15:50 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 24, 2023 19:40 Inactive
@bensheldon bensheldon added the refactor Code changes that do not introduce new features label Feb 24, 2023
@bensheldon bensheldon marked this pull request as ready for review February 24, 2023 20:46
@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 24, 2023 23:28 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 28, 2023 01:45 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-capsule-mmmpbncosrywrn February 28, 2023 02:11 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code changes that do not introduce new features
Projects
Development

Successfully merging this pull request may close these issues.

1 participant