Skip to content

Conversation

@MiniCodeMonkey
Copy link
Member

Summary

This PR adds configurable HTTP timeout values to prevent API requests from hanging indefinitely and to provide appropriate limits based on the expected duration of different operation types.

Changes

  • Added timeout constants to the Geocodio class for different operation types
  • Modified the SendsRequests trait to accept and apply timeout parameters to Guzzle requests
  • Updated geocode() method to use 5-second timeout for single requests and 30-minute timeout for batch requests
  • Updated reverse() method to use 5-second timeout for single requests and 30-minute timeout for batch requests
  • Updated all lists API methods (uploadList, uploadInlineList, listStatus, lists, downloadList, deleteList) to use 60-second timeout

Test Plan

  • All existing unit tests pass (25 tests, 78 assertions)
  • Tests\GeocodingTest suite validates geocoding operations with new timeouts
  • Tests\ListTest suite validates list operations with new timeouts
  • Tests\ErrorHandlingTest suite ensures error handling still works correctly

Implement appropriate timeout values for different API operations:
- Single geocoding requests: 5 seconds
- Batch geocoding requests: 30 minutes
- Lists API requests: 60 seconds

This prevents requests from hanging indefinitely and provides
reasonable limits based on the expected duration of each operation type.
- Add instance properties to store timeout configurations
- Add setter methods to customize timeout values per instance
- Update all API methods to use instance properties instead of constants
- Add comprehensive tests to verify timeouts are properly passed to Guzzle

This allows users to configure timeout values based on their specific needs:
```php
$geocodio->setSingleTimeoutMs(10000)  // 10 seconds
         ->setBatchTimeoutMs(3600000) // 1 hour
         ->setListsTimeoutMs(120000); // 2 minutes
```
@MiniCodeMonkey MiniCodeMonkey requested a review from sixlive August 11, 2025 07:50
@MiniCodeMonkey MiniCodeMonkey merged commit 64f8bfa into master Aug 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants