Skip to content

Conversation

@bluehaha
Copy link
Contributor

@bluehaha bluehaha commented Oct 22, 2025

This PR ports the feature from: laravel/framework#57341

@albertcht albertcht requested a review from Copilot October 22, 2025 03:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the failover queue functionality to Laravel by introducing a new FailoverQueue implementation that automatically switches between configured queue connections when failures occur. The implementation includes enhanced queue monitoring capabilities through new methods that provide detailed statistics about pending, delayed, and reserved jobs.

Key Changes:

  • Added failover queue functionality with automatic connection switching on failures
  • Introduced granular queue size methods (pending, delayed, reserved) across all queue implementations
  • Enhanced queue monitoring with detailed job statistics

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/queue/src/FailoverQueue.php New failover queue implementation with exception handling and event dispatching
src/queue/src/Connectors/FailoverConnector.php Connector for instantiating failover queues
src/queue/src/Events/QueueFailedOver.php Event fired when a queue connection fails over
src/queue/src/Contracts/Queue.php Added new interface methods for granular queue size metrics
src/queue/src/Queue.php Added config storage and accessor methods
src/queue/src/QueueManager.php Registered failover connector and updated queue resolution to set config
src/queue/src/SqsQueue.php Implemented new size methods using SQS attributes
src/queue/src/RedisQueue.php Implemented new size methods using Redis data structures
src/queue/src/DatabaseQueue.php Implemented new size methods with database queries
src/queue/src/BeanstalkdQueue.php Implemented new size methods using Beanstalkd stats
src/queue/src/SyncQueue.php Added stub implementations returning 0 for all new size methods
src/queue/src/NullQueue.php Added stub implementations returning 0 for all new size methods
src/queue/src/QueuePoolProxy.php Added proxy methods for new size methods
src/queue/src/Console/MonitorCommand.php Enhanced monitoring command to display new queue statistics
src/support/src/Testing/Fakes/QueueFake.php Added stub implementations for testing
src/queue/composer.json Updated pheanstalk version constraint
tests/Queue/FailoverQueueTest.php Added test for failover behavior
tests/Queue/QueueWorkerTest.php Added stub methods to test queue mock
tests/Queue/QueueSqsQueueTest.php Updated test to verify all SQS attributes are retrieved
tests/Queue/QueueManagerTest.php Updated tests to expect setConfig calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

*/
public function creationTimeOfOldestPendingJob(?string $queue = null): ?int
{
return 0;
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creationTimeOfOldestPendingJob method should return null instead of 0 to match the return type signature ?int and indicate no pending job, consistent with other implementations like SqsQueue and RedisQueue.

Suggested change
return 0;
return null;

Copilot uses AI. Check for mistakes.
*/
public function creationTimeOfOldestPendingJob(?string $queue = null): ?int
{
return 0;
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creationTimeOfOldestPendingJob method should return null instead of 0 to match the return type signature ?int and indicate no pending job, consistent with the semantic meaning and other implementations.

Suggested change
return 0;
return null;

Copilot uses AI. Check for mistakes.
*/
public function creationTimeOfOldestPendingJob(?string $queue = null): ?int
{
return 0;
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creationTimeOfOldestPendingJob method should return null instead of 0 to match the return type signature ?int and indicate no pending job, consistent with other implementations.

Suggested change
return 0;
return null;

Copilot uses AI. Check for mistakes.
@albertcht albertcht changed the title feat: migrate failover queue Laravel feat: migrate failover queue from Laravel Oct 22, 2025
@albertcht albertcht added the feature New feature or request label Oct 22, 2025
@albertcht albertcht merged commit 105f99e into hypervel:main Oct 22, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants