-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,437 changed files
with
51,872 additions
and
3,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ addons: | |
firefox: "46.0" | ||
hosts: | ||
- magento2.travis | ||
services: | ||
- rabbitmq | ||
language: php | ||
php: | ||
- 7.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Amqp\Model; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated 100.2.0 | ||
*/ | ||
class Config extends \Magento\Framework\Amqp\Config | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Amqp\Model; | ||
|
||
use Magento\Framework\MessageQueue\ConfigInterface as QueueConfig; | ||
use Magento\Framework\Communication\ConfigInterface as CommunicationConfigInterface; | ||
use Magento\Framework\MessageQueue\Publisher\ConfigInterface as PublisherConfig; | ||
use Magento\Framework\MessageQueue\Rpc\ResponseQueueNameBuilder; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated 100.2.0 | ||
*/ | ||
class Exchange extends \Magento\Framework\Amqp\Exchange | ||
{ | ||
/** | ||
* Initialize dependencies. | ||
* | ||
* @param Config $amqpConfig | ||
* @param QueueConfig $queueConfig | ||
* @param CommunicationConfigInterface $communicationConfig | ||
* @param int $rpcConnectionTimeout | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function __construct( | ||
Config $amqpConfig, | ||
QueueConfig $queueConfig, | ||
CommunicationConfigInterface $communicationConfig, | ||
$rpcConnectionTimeout = self::RPC_CONNECTION_TIMEOUT | ||
) { | ||
parent::__construct( | ||
$amqpConfig, | ||
$this->getPublisherConfig(), | ||
$this->getResponseQueueNameBuilder(), | ||
$communicationConfig, | ||
$rpcConnectionTimeout | ||
); | ||
} | ||
|
||
/** | ||
* Get publisher config. | ||
* | ||
* @return PublisherConfig | ||
* | ||
* @deprecated 100.2.0 | ||
*/ | ||
private function getPublisherConfig() | ||
{ | ||
return \Magento\Framework\App\ObjectManager::getInstance()->get(PublisherConfig::class); | ||
} | ||
|
||
/** | ||
* Get response queue name builder. | ||
* | ||
* @return ResponseQueueNameBuilder | ||
* | ||
* @deprecated 100.2.0 | ||
*/ | ||
private function getResponseQueueNameBuilder() | ||
{ | ||
return \Magento\Framework\App\ObjectManager::getInstance()->get(ResponseQueueNameBuilder::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Amqp\Model; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated 100.2.0 | ||
*/ | ||
class Queue extends \Magento\Framework\Amqp\Queue | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Amqp\Model; | ||
|
||
use Magento\Framework\Amqp\Topology\ExchangeInstaller; | ||
use Magento\Framework\Amqp\Topology\QueueInstaller; | ||
use Magento\Framework\MessageQueue\ConfigInterface as QueueConfig; | ||
use Magento\Framework\Communication\ConfigInterface as CommunicationConfig; | ||
use Magento\Framework\MessageQueue\Topology\ConfigInterface as TopologyConfig; | ||
use Magento\Framework\Amqp\ConfigPool; | ||
use Magento\Framework\Amqp\ConnectionTypeResolver; | ||
use Magento\Framework\Amqp\TopologyInstaller; | ||
|
||
/** | ||
* Class Topology creates topology for Amqp messaging | ||
* | ||
* @deprecated 100.2.0 | ||
*/ | ||
class Topology extends TopologyInstaller | ||
{ | ||
/** | ||
* Type of exchange | ||
* | ||
* @deprecated | ||
*/ | ||
const TOPIC_EXCHANGE = 'topic'; | ||
|
||
/** | ||
* Amqp connection | ||
*/ | ||
const AMQP_CONNECTION = 'amqp'; | ||
|
||
/** | ||
* Durability for exchange and queue | ||
* | ||
* @deprecated | ||
*/ | ||
const IS_DURABLE = true; | ||
|
||
/** | ||
* Initialize dependencies | ||
* | ||
* @param Config $amqpConfig | ||
* @param QueueConfig $queueConfig | ||
* @param CommunicationConfig $communicationConfig | ||
* @param \Psr\Log\LoggerInterface $logger | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function __construct( | ||
Config $amqpConfig, | ||
QueueConfig $queueConfig, | ||
CommunicationConfig $communicationConfig, | ||
\Psr\Log\LoggerInterface $logger | ||
) { | ||
parent::__construct( | ||
\Magento\Framework\App\ObjectManager::getInstance()->get(TopologyConfig::class), | ||
\Magento\Framework\App\ObjectManager::getInstance()->get(ExchangeInstaller::class), | ||
\Magento\Framework\App\ObjectManager::getInstance()->get(ConfigPool::class), | ||
\Magento\Framework\App\ObjectManager::getInstance()->get(QueueInstaller::class), | ||
\Magento\Framework\App\ObjectManager::getInstance()->get(ConnectionTypeResolver::class), | ||
$logger | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Amqp | ||
|
||
**Amqp** provides functionality to publish/consume messages with Amqp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Amqp\Setup; | ||
|
||
use Magento\Framework\Config\Data\ConfigData; | ||
use Magento\Framework\Config\File\ConfigFilePool; | ||
use Magento\Framework\Setup\ConfigOptionsListInterface; | ||
use Magento\Framework\Setup\Option\TextConfigOption; | ||
use Magento\Framework\App\DeploymentConfig; | ||
|
||
/** | ||
* Deployment configuration options needed for Setup application | ||
*/ | ||
class ConfigOptionsList implements ConfigOptionsListInterface | ||
{ | ||
/** | ||
* Input key for the options | ||
*/ | ||
const INPUT_KEY_QUEUE_AMQP_HOST = 'amqp-host'; | ||
const INPUT_KEY_QUEUE_AMQP_PORT = 'amqp-port'; | ||
const INPUT_KEY_QUEUE_AMQP_USER = 'amqp-user'; | ||
const INPUT_KEY_QUEUE_AMQP_PASSWORD = 'amqp-password'; | ||
const INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST = 'amqp-virtualhost'; | ||
const INPUT_KEY_QUEUE_AMQP_SSL = 'amqp-ssl'; | ||
|
||
/** | ||
* Path to the values in the deployment config | ||
*/ | ||
const CONFIG_PATH_QUEUE_AMQP_HOST = 'queue/amqp/host'; | ||
const CONFIG_PATH_QUEUE_AMQP_PORT = 'queue/amqp/port'; | ||
const CONFIG_PATH_QUEUE_AMQP_USER = 'queue/amqp/user'; | ||
const CONFIG_PATH_QUEUE_AMQP_PASSWORD = 'queue/amqp/password'; | ||
const CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST = 'queue/amqp/virtualhost'; | ||
const CONFIG_PATH_QUEUE_AMQP_SSL = 'queue/amqp/ssl'; | ||
|
||
/** | ||
* Default values | ||
*/ | ||
const DEFAULT_AMQP_HOST = ''; | ||
const DEFAULT_AMQP_PORT = '5672'; | ||
const DEFAULT_AMQP_USER = ''; | ||
const DEFAULT_AMQP_PASSWORD = ''; | ||
const DEFAULT_AMQP_VIRTUAL_HOST = '/'; | ||
const DEFAULT_AMQP_SSL = ''; | ||
|
||
/** | ||
* @var ConnectionValidator | ||
*/ | ||
private $connectionValidator; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ConnectionValidator $connectionValidator | ||
*/ | ||
public function __construct(ConnectionValidator $connectionValidator) | ||
{ | ||
$this->connectionValidator = $connectionValidator; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getOptions() | ||
{ | ||
return [ | ||
new TextConfigOption( | ||
self::INPUT_KEY_QUEUE_AMQP_HOST, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_QUEUE_AMQP_HOST, | ||
'Amqp server host', | ||
self::DEFAULT_AMQP_HOST | ||
), | ||
new TextConfigOption( | ||
self::INPUT_KEY_QUEUE_AMQP_PORT, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_QUEUE_AMQP_PORT, | ||
'Amqp server port', | ||
self::DEFAULT_AMQP_PORT | ||
), | ||
new TextConfigOption( | ||
self::INPUT_KEY_QUEUE_AMQP_USER, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_QUEUE_AMQP_USER, | ||
'Amqp server username', | ||
self::DEFAULT_AMQP_USER | ||
), | ||
new TextConfigOption( | ||
self::INPUT_KEY_QUEUE_AMQP_PASSWORD, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_QUEUE_AMQP_PASSWORD, | ||
'Amqp server password', | ||
self::DEFAULT_AMQP_PASSWORD | ||
), | ||
new TextConfigOption( | ||
self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST, | ||
'Amqp virtualhost', | ||
self::DEFAULT_AMQP_VIRTUAL_HOST | ||
), | ||
new TextConfigOption( | ||
self::INPUT_KEY_QUEUE_AMQP_SSL, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_QUEUE_AMQP_SSL, | ||
'Amqp SSL', | ||
self::DEFAULT_AMQP_SSL | ||
), | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function createConfig(array $data, DeploymentConfig $deploymentConfig) | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
|
||
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_HOST)) { | ||
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_HOST, $data[self::INPUT_KEY_QUEUE_AMQP_HOST]); | ||
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_PORT)) { | ||
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_PORT, $data[self::INPUT_KEY_QUEUE_AMQP_PORT]); | ||
} | ||
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_USER)) { | ||
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_USER, $data[self::INPUT_KEY_QUEUE_AMQP_USER]); | ||
} | ||
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_PASSWORD)) { | ||
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_PASSWORD, $data[self::INPUT_KEY_QUEUE_AMQP_PASSWORD]); | ||
} | ||
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST)) { | ||
$configData->set( | ||
self::CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST, | ||
$data[self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST] | ||
); | ||
} | ||
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_SSL)) { | ||
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_SSL, $data[self::INPUT_KEY_QUEUE_AMQP_SSL]); | ||
} | ||
} | ||
|
||
return [$configData]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate(array $options, DeploymentConfig $deploymentConfig) | ||
{ | ||
$errors = []; | ||
|
||
if (isset($options[self::INPUT_KEY_QUEUE_AMQP_HOST]) | ||
&& $options[self::INPUT_KEY_QUEUE_AMQP_HOST] !== '') { | ||
$result = $this->connectionValidator->isConnectionValid( | ||
$options[self::INPUT_KEY_QUEUE_AMQP_HOST], | ||
$options[self::INPUT_KEY_QUEUE_AMQP_PORT], | ||
$options[self::INPUT_KEY_QUEUE_AMQP_USER], | ||
$options[self::INPUT_KEY_QUEUE_AMQP_PASSWORD], | ||
$options[self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST] | ||
); | ||
|
||
if (!$result) { | ||
$errors[] = "Could not connect to the Amqp Server."; | ||
} | ||
} | ||
|
||
return $errors; | ||
} | ||
|
||
/** | ||
* Check if data ($data) with key ($key) is empty | ||
* | ||
* @param array $data | ||
* @param string $key | ||
* @return bool | ||
*/ | ||
private function isDataEmpty(array $data, $key) | ||
{ | ||
if (isset($data[$key]) && $data[$key] !== '') { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.