-
Notifications
You must be signed in to change notification settings - Fork 235
Test/queue runner refacto #7905
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
Draft
Miraeld
wants to merge
18
commits into
develop
Choose a base branch
from
test/queue-runner-refacto
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2b14449
feat: Create AbstractQueueRunner base class
Miraeld f6b6f2b
refactor: Update RUCSSQueueRunner to extend AbstractQueueRunner
Miraeld 2a95d57
feat: Create RocketInsights QueueRunner with 30-second intervals
Miraeld 652dfe8
feat: Register RocketInsights QueueRunner in ServiceProvider
Miraeld bc11d0d
feat: Initialize RocketInsights QueueRunner via Subscriber
Miraeld 1773d2f
add temporary log
Miraeld 7310508
refactor: create AbstractQueueRunner base class
Miraeld b4889bd
feat: refactor RUCSSQueueRunner to extend AbstractQueueRunner
Miraeld c9b5b0e
feat: create RocketInsights QueueRunner with 30-second intervals
Miraeld fa775fc
fix: enhance Queue class with dynamic group assignment
Miraeld a18c730
fix: use Queue factory methods for proper group assignment
Miraeld 60f9107
fix: remove unused queue parameter from JobProcessor constructor
Miraeld 1d370ab
fix: implement complete do_batch method and fix PHPStan errors
Miraeld 6d85b8f
fix: address Copilot review feedback
Miraeld 2b98f6b
fix: PHPCS compliance for AbstractQueueRunner
Miraeld 2d53082
feat: register RocketInsights QueueRunner in ServiceProvider
Miraeld 275c6e1
feat: add proper cleanup logic for RocketInsights QueueRunner
Miraeld 64ea97d
feat: add RocketInsights queue runner cron to uninstall cleanup
Miraeld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| <?php | ||
| declare( strict_types=1 ); | ||
|
|
||
| namespace WP_Rocket\Engine\Admin\RocketInsights\Queue; | ||
|
|
||
| use WP_Rocket\Engine\Common\Queue\AbstractQueueRunner; | ||
| use WP_Rocket\Engine\Common\Queue\Cleaner; | ||
| use ActionScheduler_Store; | ||
| use ActionScheduler_FatalErrorMonitor; | ||
| use ActionScheduler_AsyncRequest_QueueRunner; | ||
|
|
||
| /** | ||
| * Rocket Insights Queue Runner | ||
| * | ||
| * Manages Action Scheduler jobs for Rocket Insights workflow | ||
| * Processes jobs every 30 seconds instead of the default 60 seconds | ||
| * | ||
| * @since 3.20 | ||
| */ | ||
| class QueueRunner extends AbstractQueueRunner { | ||
|
|
||
| /** | ||
| * Cron hook name. | ||
| */ | ||
| const WP_CRON_HOOK = 'action_scheduler_run_queue_rocket_insights'; | ||
|
|
||
| /** | ||
| * Cron schedule interval. | ||
| */ | ||
| const WP_CRON_SCHEDULE = 'every_thirty_seconds'; | ||
|
|
||
| /** | ||
| * Current runner instance. | ||
| * | ||
| * @var QueueRunner Instance. | ||
| */ | ||
| private static $runner = null; | ||
|
|
||
| /** | ||
| * Get singleton instance. | ||
| * | ||
| * @since 3.20 | ||
| * | ||
| * @return QueueRunner Instance. | ||
| */ | ||
| public static function instance() { | ||
| if ( null === self::$runner ) { | ||
| self::$runner = new QueueRunner(); | ||
| } | ||
| return self::$runner; | ||
| } | ||
|
|
||
| /** | ||
| * Add the cron schedule for Rocket Insights (every 30 seconds). | ||
| * | ||
| * @since 3.20 | ||
| * | ||
| * @param array $schedules Array of current schedules. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function add_wp_cron_schedule( $schedules ) { | ||
| if ( isset( $schedules['every_thirty_seconds'] ) ) { | ||
| return $schedules; | ||
| } | ||
|
|
||
| $schedules['every_thirty_seconds'] = [ | ||
| 'interval' => 30, // in seconds. | ||
| 'display' => __( 'Every thirty seconds', 'rocket' ), | ||
| ]; | ||
|
|
||
| return $schedules; | ||
| } | ||
|
|
||
| /** | ||
| * Get the cron hook name. | ||
| * | ||
| * @since 3.20 | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function get_wp_cron_hook(): string { | ||
| return self::WP_CRON_HOOK; | ||
| } | ||
|
|
||
| /** | ||
| * Get the cron schedule interval. | ||
| * | ||
| * @since 3.20 | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function get_wp_cron_schedule(): string { | ||
| return self::WP_CRON_SCHEDULE; | ||
| } | ||
|
|
||
| /** | ||
| * Get the queue group name. | ||
| * | ||
| * @since 3.20 | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function get_group(): string { | ||
| return 'rocket-insights'; | ||
| } | ||
|
|
||
| /** | ||
| * Process a batch of jobs. | ||
| * | ||
| * @param int $size The maximum number of actions to process. | ||
| * @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI'. | ||
| * | ||
| * @return int The number of actions processed. | ||
| */ | ||
| protected function do_batch( $size = 100, $context = '' ) { | ||
| $processed = parent::do_batch( $size, $context ); | ||
| return $processed; | ||
| } | ||
Miraeld marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.