-
Notifications
You must be signed in to change notification settings - Fork 4
Increment attempts
before each attempt
#167
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
Conversation
There was a problem hiding this 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 refactors EventManager
and Data
to support dependency injection of the event queue, moves the call to increment_attempt
so it runs before each batch send attempt, and updates tests to use mocks instead of Patchwork redefines. It also adjusts the default attempt count for pageview events in BatchQueue
and adds an integration test for retry logic.
- Inject
EventQueue
intoEventManager
andData
, replacing static calls - Call
increment_attempt
at the start ofsend_saved_events_batch
- Update PHPUnit tests to mock
EventQueue
andEventManager
directly - Adjust default
attempts
for"pageview"
events inBatchQueue
- Add an integration test verifying retry limits
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
includes/EventManager.php | Added constructor injection, replaced static queue calls, moved increment_attempt earlier in batch send |
includes/Data.php | Accepts injected EventManager instead of instantiating internally |
includes/EventQueue/Queues/BatchQueue.php | Set pageview events to 0 initial attempts, updated comment |
includes/HiiveConnection.php | Improved docblock types for connect parameters |
tests/phpunit/includes/EventManagerTest.php | Refactored tests to use injected EventQueue mocks |
tests/phpunit/includes/DataTest.php | Updated tests to inject EventManager mocks |
tests/integration/EventManagerIntegrationTest.php | New integration test for batch retry behavior |
Comments suppressed due to low confidence (2)
includes/EventQueue/Queues/BatchQueue.php:89
- Add a unit test to verify that events with key
'pageview'
initializeattempts
to 0 and are not sent synchronously, ensuring this conditional behavior is covered.
'pageview' === $event->key ? 0 : 1
includes/EventManager.php:52
- [nitpick] The property
$queue
is ambiguous alongside$event_queue
; consider renaming it to$pendingEvents
or similar to clarify its purpose.
private $queue = array();
Proposed changes
Previously, if there was a failure sending the events, e.g. connection failure, 500, the call to
BatchQueue::increment_attempt()
never ran.This PR moves that call to happen before sending the event is attempted.
Type of Change
Production
Development
Video
Checklist
Further comments