Skip to content

Commit 2a6cddd

Browse files
committed
MC-13613: Product mass update
1 parent 3808c33 commit 2a6cddd

File tree

8 files changed

+14
-80
lines changed

8 files changed

+14
-80
lines changed

app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\MessageQueue\Api;
99

10-
use Magento\MessageQueue\Api\Data\PoisonPillInterface;
11-
1210
/**
1311
* Interface describes how to describes how to compare poison pill with latest in DB.
1412
*
@@ -19,8 +17,8 @@ interface PoisonPillCompareInterface
1917
/**
2018
* Check if version of current poison pill is latest.
2119
*
22-
* @param PoisonPillInterface $poisonPill
20+
* @param int $poisonPillVersion
2321
* @return bool
2422
*/
25-
public function isLatest(PoisonPillInterface $poisonPill): bool;
23+
public function isLatestVersion(int $poisonPillVersion): bool;
2624
}

app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\MessageQueue\Api;
99

10-
use Magento\MessageQueue\Api\Data\PoisonPillInterface;
11-
1210
/**
1311
* Describes how to get latest version of poison pill.
1412
*
@@ -17,9 +15,9 @@
1715
interface PoisonPillReadInterface
1816
{
1917
/**
20-
* Returns latest poison pill.
18+
* Returns get latest version of poison pill.
2119
*
22-
* @return PoisonPillInterface
20+
* @return int
2321
*/
24-
public function getLatest(): PoisonPillInterface;
22+
public function getLatestVersion(): int;
2523
}

app/code/Magento/MessageQueue/Model/CallbackInvoker.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Magento\Framework\MessageQueue\CallbackInvokerInterface;
1111
use Magento\Framework\MessageQueue\QueueInterface;
12-
use Magento\MessageQueue\Api\Data\PoisonPillInterface;
1312
use Magento\MessageQueue\Api\PoisonPillCompareInterface;
1413
use Magento\MessageQueue\Api\PoisonPillReadInterface;
1514

@@ -24,9 +23,9 @@ class CallbackInvoker implements CallbackInvokerInterface
2423
private $poisonPillRead;
2524

2625
/**
27-
* @var PoisonPillInterface $poisonPill
26+
* @var int $poisonPillVersion
2827
*/
29-
private $poisonPill;
28+
private $poisonPillVersion;
3029

3130
/**
3231
* @var PoisonPillCompareInterface
@@ -51,12 +50,12 @@ public function __construct(
5150
*/
5251
public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback)
5352
{
54-
$this->poisonPill = $this->poisonPillRead->getLatest();
53+
$this->poisonPillVersion = $this->poisonPillRead->getLatestVersion();
5554
for ($i = $maxNumberOfMessages; $i > 0; $i--) {
5655
do {
5756
$message = $queue->dequeue();
5857
} while ($message === null && (sleep(1) === 0));
59-
if (false === $this->poisonPillCompare->isLatest($this->poisonPill)) {
58+
if (false === $this->poisonPillCompare->isLatestVersion($this->poisonPillVersion)) {
6059
$queue->reject($message);
6160
exit(0);
6261
}

app/code/Magento/MessageQueue/Model/PoisonPill.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/code/Magento/MessageQueue/Model/PoisonPillCompare.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\MessageQueue\Model;
99

10-
use Magento\MessageQueue\Api\Data\PoisonPillInterface;
1110
use Magento\MessageQueue\Api\PoisonPillCompareInterface;
1211
use Magento\MessageQueue\Api\PoisonPillReadInterface;
1312

@@ -34,8 +33,8 @@ public function __construct(
3433
/**
3534
* @inheritdoc
3635
*/
37-
public function isLatest(PoisonPillInterface $poisonPill): bool
36+
public function isLatestVersion(int $poisonPillVersion): bool
3837
{
39-
return $poisonPill->getVersion() === $this->poisonPillRead->getLatest()->getVersion();
38+
return $poisonPillVersion === $this->poisonPillRead->getLatestVersion();
4039
}
4140
}

app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\MessageQueue\Model\ResourceModel;
99

10-
use Magento\MessageQueue\Api\Data\PoisonPillInterface;
11-
use Magento\MessageQueue\Api\Data\PoisonPillInterfaceFactory;
1210
use Magento\MessageQueue\Api\PoisonPillReadInterface;
1311
use Magento\MessageQueue\Api\PoisonPillPutInterface;
1412
use Magento\Framework\Model\ResourceModel\Db\Context;
@@ -24,24 +22,16 @@ class PoisonPill extends AbstractDb implements PoisonPillPutInterface, PoisonPil
2422
*/
2523
const QUEUE_POISON_PILL_TABLE = 'queue_poison_pill';
2624

27-
/**
28-
* @var PoisonPillInterfaceFactory
29-
*/
30-
private $poisonPillFactory;
31-
3225
/**
3326
* PoisonPill constructor.
3427
*
3528
* @param Context $context
36-
* @param PoisonPillInterfaceFactory $poisonPillFactory
3729
* @param string|null $connectionName
3830
*/
3931
public function __construct(
4032
Context $context,
41-
PoisonPillInterfaceFactory $poisonPillFactory,
4233
string $connectionName = null
4334
) {
44-
$this->poisonPillFactory = $poisonPillFactory;
4535
parent::__construct($context, $connectionName);
4636
}
4737

@@ -67,7 +57,7 @@ public function put(): int
6757
/**
6858
* @inheritdoc
6959
*/
70-
public function getLatest() : PoisonPillInterface
60+
public function getLatestVersion() : int
7161
{
7262
$select = $this->getConnection()->select()->from(
7363
$this->getTable(self::QUEUE_POISON_PILL_TABLE),
@@ -78,10 +68,8 @@ public function getLatest() : PoisonPillInterface
7868
1
7969
);
8070

81-
$version = $this->getConnection()->fetchOne($select);
82-
83-
$poisonPill = $this->poisonPillFactory->create(['data' => ['version' => (int) $version]]);
71+
$version = (int)$this->getConnection()->fetchOne($select);
8472

85-
return $poisonPill;
73+
return $version;
8674
}
8775
}

app/code/Magento/MessageQueue/etc/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<preference for="Magento\Framework\MessageQueue\EnvelopeInterface" type="Magento\Framework\MessageQueue\Envelope"/>
1414
<preference for="Magento\Framework\MessageQueue\ConsumerInterface" type="Magento\Framework\MessageQueue\Consumer"/>
1515
<preference for="Magento\Framework\MessageQueue\MergedMessageInterface" type="Magento\Framework\MessageQueue\MergedMessage"/>
16-
<preference for="Magento\MessageQueue\Api\Data\PoisonPillInterface" type="Magento\MessageQueue\Model\PoisonPill"/>
1716
<preference for="Magento\MessageQueue\Api\PoisonPillCompareInterface" type="Magento\MessageQueue\Model\PoisonPillCompare"/>
1817
<preference for="Magento\MessageQueue\Api\PoisonPillPutInterface" type="Magento\MessageQueue\Model\ResourceModel\PoisonPill"/>
1918
<preference for="Magento\MessageQueue\Api\PoisonPillReadInterface" type="Magento\MessageQueue\Model\ResourceModel\PoisonPill"/>

0 commit comments

Comments
 (0)