Add service for automatic decrease sending batch size

[MAILPOET-3588]
This commit is contained in:
Jan Lysý
2021-04-30 13:11:00 +02:00
committed by Veljko V
parent 74b6c3bfe3
commit 6a9e692f64
6 changed files with 110 additions and 7 deletions

View File

@@ -7,6 +7,13 @@ use MailPoet\Mailer\MailerLog;
use MailPoet\Tasks\Sending as SendingTask;
class SendingErrorHandler {
/** @var SendingThrottlingHandler */
private $throttlingHandler;
public function __construct(SendingThrottlingHandler $throttlingHandler) {
$this->throttlingHandler = $throttlingHandler;
}
public function processError(
MailerError $error,
SendingTask $sendingTask,
@@ -23,7 +30,11 @@ class SendingErrorHandler {
if ($error->getRetryInterval() !== null) {
MailerLog::processNonBlockingError($error->getOperation(), $error->getMessageWithFailedSubscribers(), $error->getRetryInterval());
} else {
MailerLog::processError($error->getOperation(), $error->getMessageWithFailedSubscribers());
$throttledBatchSize = null;
if ($error->getOperation() === MailerError::OPERATION_CONNECT) {
$throttledBatchSize = $this->throttlingHandler->throttleBatchSize();
}
MailerLog::processError($error->getOperation(), $error->getMessageWithFailedSubscribers(), null, false, $throttledBatchSize);
}
}