added retries back to mail functionality

This commit is contained in:
2021-03-18 18:25:26 +09:00
parent c27a9c3f85
commit b91925a3f6
2 changed files with 30 additions and 11 deletions

View File

@@ -37,10 +37,10 @@ class ProcessSendEveMailJob implements ShouldQueue
/**
* Retries
* With new rate limiting, we shouldn't use this timeout
* With new rate limiting, we need a retry basis versus timeout basis
* @var int
*/
//public $retries = 3;
public $retries = 5;
private $sender;
private $body;
@@ -166,6 +166,9 @@ class ProcessSendEveMailJob implements ShouldQueue
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
$rateLimitedMiddleware = (new RateLimited())
->enabled()
->key('psemj')
->connectionName('redis')
->allow(4)
->everySeconds(60)
->releaseAfterOneMinute()

View File

@@ -42,13 +42,6 @@ class ProcessSendEveMailJobRL implements ShouldQueue
*/
//public $retries = 3;
/**
* Middleware for the job
*
* @var \Spatie\RateLimitedMiddleware\RateLimited
*/
private $middleware;
private $sender;
private $body;
private $recipient;
@@ -126,9 +119,11 @@ class ProcessSendEveMailJobRL implements ShouldQueue
*
*/
public function middleware() {
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
$rateLimitedMiddleware = (new RateLimited())
->enabled()
->key('PSEMJ')
->connectionName('redis')
->allow(4)
->everySeconds(60)
->releaseAfterOneMinute()
@@ -137,6 +132,27 @@ class ProcessSendEveMailJobRL implements ShouldQueue
return [$rateLimitedMiddleware];
}
private function OtherCode() {
//Can also specify middleware when dispatch a job.
//SomeJob::dispatch()->through([new SomeMiddleware]);
//Current method of creating job handle with redis throttle
/**
* public function handle()
* {
* Redis::throttle('key')->allow(10)->every(60)->then(function () {
* // Job logic...
* }, function () {
* // Could not obtain lock...
* return $this->release(10);
* });
* }
*/
}
/*
* Determine the time at which the job should timeout.
*