Skip to content

Commit

Permalink
+ RetryableJobInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
Leoncio, Leo committed Apr 1, 2024
1 parent 9be07de commit f5451b4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/jobs/EmailJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

use craft\queue\BaseJob;
use leowebguy\simplelogger\SimpleLogger;
use yii\queue\RetryableJobInterface;

class EmailJob extends BaseJob
class EmailJob extends BaseJob implements RetryableJobInterface
{
public array $to;

Expand All @@ -21,6 +22,16 @@ public function defaultDescription(): string
return 'Sending Simple Logger Report';
}

public function getTtr(): float|int
{
return 15 * 60;
}

public function canRetry($attempt, $error): bool
{
return ($attempt < 2) && ($error instanceof TemporaryException);
}

public function execute($queue): void
{
SimpleLogger::getInstance()->loggerService->sendMail($this->to);
Expand Down

0 comments on commit f5451b4

Please sign in to comment.