PHP client should throw an exception / response for rate limit (429)
Closed this issue · 1 comments
Background
As a user, I want to handle 429 errors received by the server and implement a retry mechanism.
Problem
As of today, the site-search-php
throws a general exception for 429 error code without any response details regarding the rate limit. Based on the documentation, there are two response headers which provide a guideline towards the rate limit. Without information related to the rate limit, the caller cannot implement such retry mechanism.
Possible solution
Similiar to the app-search-php client, the site-search-php
client could also return a specific exception so that the caller can handle rate limit.
PR #8 fix this issue.
An exception (\Elastic\SiteSearch\Client\Exception\ApiRateExceededException
) is thrown when the request is rate limited.
Additionally, a warning is logged (if using a logger) on every request when the consumed rate limit percentage is over 90% for the request type.