Skip to content

Commit d40a669

Browse files
committed
Update readme
1 parent 200d0da commit d40a669

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ When calling `collect()`, we indicate that the pagination structure is defined a
8282

8383
### 💧 Sources
8484

85-
A source is any mean that can point to a paginated JSON API. A number of sources is supported by default:
85+
A source is any means that can point to a paginated JSON API. A number of sources is supported by default:
8686

8787
- **endpoint URIs**, e.g. `https://example.com/api/v1/users` or any instance of `Psr\Http\Message\UriInterface`
8888
- **PSR-7 requests**, i.e. any instance of `Psr\Http\Message\RequestInterface`
@@ -307,7 +307,7 @@ If we need a middleware to be added every time we invoke Lazy JSON Pages, we can
307307
LazyJsonPages::globalMiddleware('fire_events', $fireEvents);
308308
```
309309

310-
Sometimes writing Guzzle middleware might be cumbersome, alternatively Lazy JSON Pages provides convenient methods to fire callbacks when sending a request, receiving a response or dealing with a transaction error:
310+
Sometimes writing Guzzle middleware might be cumbersome. Alternatively Lazy JSON Pages provides convenient methods to fire callbacks when sending a request, receiving a response or dealing with a transaction error:
311311

312312
```php
313313
use Psr\Http\Message\RequestInterface;
@@ -319,6 +319,15 @@ LazyJsonPages::from($source)
319319
->onError(fn(Throwable $e, RequestInterface $request, ?ResponseInterface $response) => ...);
320320
```
321321

322+
Several APIs set rate limits to limitate the number of allowed requests for a period of time. We can instruct Lazy JSON Pages to respect such limits by throttling our requests:
323+
324+
```php
325+
// we send a maximum of 3 requests per second, 60 per minute and 3,000 per hour
326+
LazyJsonPages::from($source)
327+
->throttle(requests: 3, perSeconds: 1)
328+
->throttle(requests: 60, perMinutes: 1)
329+
->throttle(requests: 3000, perHours: 1);
330+
```
322331

323332
### 💢 Errors handling
324333

0 commit comments

Comments
 (0)