DEPRECATED: use a built-in queue agnostic implementation throttle mechanism from Laravel Framework
Register service provider by adding in config/app.php
'providers' => [
// Other Service Providers
Likewinter\QueueThrottle\QueueThrottleServiceProvider::class
],
Register service provider by adding in bootstrap/app.php
$app->register(Likewinter\QueueThrottle\QueueThrottleServiceProvider::class);
You can set Redis and Beanstalkd hosts in your .env file like
BEANSTALKD_HOST=beanstalkd
REDIS_HOST=redis
Inside your Job class add trait and set limits
use CanLimitRate;
protected $rateLimits = [
['requests' => 10, 'seconds' => 10],
['requests' => 15, 'seconds' => 30],
];
At the begining of handle()
method use throttle
$this->throttle();