🔄 Refactor: Additional Refactoring of Jobs#4549
🔄 Refactor: Additional Refactoring of Jobs#4549MrAdder wants to merge 22 commits intoVATSIM-UK:mainfrom
Conversation
|
Removed the Refactor for the Forums as its now been removed |
|
@kristiankunc or @CLC0609 These work fine locally and will not break the site, due to restrictions on my side I can not test the full functionality to Helpdesk or moodle so thats all that will need testing |
There was a problem hiding this comment.
Pull request overview
This PR adds consistent queue configuration, rate limiting, overlap protection, structured logging, and failure handling across MSHIP sync jobs and Training jobs. It also updates Horizon worker configuration to consume the new dedicated queues.
Changes:
- Added
$tries,$backoff, dedicated queues,middleware()(rate limiting + overlap protection),failed()handler, and structured logging to all MSHIP sync and Training jobs. - Updated Horizon config to include new dedicated service queues (
helpdesk,moodle,cts,training-retention,training-eligibility). - Added configuration tests for both MSHIP and Training jobs.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
config/horizon.php |
Added new dedicated queues to production and local supervisors |
app/Listeners/Discord/SetupDiscordUser.php |
Removed explicit ->onQueue('default') to let job self-route |
app/Jobs/Mship/SyncToDiscord.php |
Added logging, failed(), updated backoff, added WithoutOverlapping options |
app/Jobs/Mship/SyncToCTS.php |
Added queue config, middleware, logging, failed() handler |
app/Jobs/Mship/SyncToHelpdesk.php |
Added queue config, middleware, logging, failed() handler |
app/Jobs/Mship/SyncToMoodle.php |
Added queue config, middleware, logging, failed() handler |
app/Jobs/Training/UpdateAccountWaitingListEligibility.php |
Added queue config, middleware, logging, failed() handler |
app/Jobs/Training/SendWaitingListRetentionCheck.php |
Added queue config, middleware, logging, failed() handler |
app/Jobs/Training/ActionWaitingListRetentionCheckRemoval.php |
Added queue config, middleware, logging, failed() handler |
tests/Unit/Jobs/Mship/SyncJobConfigurationTest.php |
New test validating MSHIP job config and middleware |
tests/Unit/Jobs/Training/TrainingJobConfigurationTest.php |
New test validating Training job config and middleware |
tests/Unit/Training/.../WaitingListRetentionChecksNotificationsTest.php |
Updated assertion to verify structured log context |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
I turned a setting on when I got my student benefits will turn of copilot reviews in morning |
Refs #4550
Summary
This PR introduces consistent queue configuration, rate limiting, overlap protection, and improved observability across MSHIP and Training jobs. It also updates Horizon to ensure the new dedicated queues are actively consumed by workers.
The goal is to:
MSHIP Sync Jobs
Updated the following jobs:
SyncToCTSSyncToDiscordSyncToHelpdeskSyncToMoodleChanges
Accountproperty.$tries = 3$backoff = 30$queueper service (cts,discord,forums,helpdesk,moodle)failed(Throwable $exception)logging.RateLimitedWithRedis('<service>-sync')WithoutOverlapping($accountId)with:releaseAfter(5)expireAfter(120)This ensures:
Training Jobs
Updated:
ActionWaitingListRetentionCheckRemovalSendWaitingListRetentionCheckUpdateAccountWaitingListEligibilityChanges
$tries = 3$backoff(30 for retention jobs, 15 for eligibility)training-retentiontraining-eligibilityfailed(Throwable $exception)logging.RateLimitedWithRedis(...)WithoutOverlapping(...)with scoped keys:retention-check:{id}waiting-list-account:{id}account:{id}Behaviour Improvements
Discord Listener Adjustment
SetupDiscordUser:->onQueue('default').SyncToDiscordto self-route to the dedicateddiscordqueue.This aligns job routing with the new queue architecture.
Horizon Configuration
Updated
config/horizon.php:Queues now include:
This ensures dedicated service queues are actually consumed by workers in both
productionandlocal.Tests Added
MSHIP
SyncJobConfigurationTesttriesbackoffRateLimitedWithRedis,WithoutOverlapping)Training
TrainingJobConfigurationTestResult
This PR:
This lays groundwork for safer horizontal scaling and improved operational visibility.