Skip to content

Commit

Permalink
README Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammyjo20 committed May 20, 2023
1 parent fe79cb8 commit a90bc1e
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ composer require saloonhttp/rate-limit-plugin

## Getting Started

To install the plugin, at the `HasRateLimit` trait to your connector or request. It's recommended that if you have
To install the plugin, add the `HasRateLimit` trait to your connector or request. It's recommended that if you have
a connector, you should put it on the connector, but it can be put on an individual request if a specific endpoint has
a different rate-limit or if you are using solo requests.

Expand Down Expand Up @@ -240,6 +240,21 @@ protected function resolveLimits(): array
}
```

### Sleep
If would rather Saloon didn't throw an exception, you can use the `sleep` method when defining a limit. When using the sleep method,
an exception won't be thrown. Instead, Saloon will wait the remaining number of seconds before a request is attempted again.

```php
use Saloon\RateLimitPlugin\Limit;

protected function resolveLimits(): array
{
return [
Limit::allow(60)->sleep(),
];
}
```

### "429: Too Many Attempts" Detection

While it's recommended that you should define your limits above, Saloon will try to catch 429 "Too Many Attempts" errors
Expand Down Expand Up @@ -306,22 +321,6 @@ try {
}
```

### Sleep

If would rather Saloon didn't throw an exception, you can use the `sleep` method when defining a limit. When using the sleep method,
an exception won't be thrown. Instead, Saloon will wait the remaining number of seconds before a request is attempted again.

```php
use Saloon\RateLimitPlugin\Limit;

protected function resolveLimits(): array
{
return [
Limit::allow(60)->sleep(),
];
}
```

### Laravel Job Middleware

If you are using Laravel, then this library comes with a [job middleware](https://laravel.com/docs/queues#job-middleware) that you can use. This job middleware will catch
Expand Down

0 comments on commit a90bc1e

Please sign in to comment.