Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move instantiation of EventBridge client out of notifier constructor. #11

Merged
merged 1 commit into from
May 8, 2023

Conversation

aligent-lturner
Copy link
Contributor

  • Also check all necessary config values are set

Currently, if the EventBridge notifier module is present (and enabled), but config settings are not saved, it will cause an exception to be thrown during the starting of cron consumers:

Missing required client configuration options: 

region: (string)

  A "region" configuration value is required for the "eventbridge" service
  (e.g., "us-west-2"). A list of available public regions and endpoints can be
  found at http://docs.aws.amazon.com/general/latest/gr/rande.html.
#0 /app/ajrszs34qiro2_stg/vendor/aws/aws-sdk-php/src/ClientResolver.php(349): Aws\ClientResolver->throwRequired(Array)
#1 /app/ajrszs34qiro2_stg/vendor/aws/aws-sdk-php/src/AwsClient.php(221): Aws\ClientResolver->resolve(Array, Object(Aws\HandlerList))
#2 /app/ajrszs34qiro2_stg/vendor/aws/aws-sdk-php/src/EventBridge/EventBridgeClient.php(124): Aws\AwsClient->__construct(Array)
#3 /app/ajrszs34qiro2_stg/vendor/aligent/magento2-eventbridge-notifier/Service/EventBridgeNotifier.php(63): Aws\EventBridge\EventBridgeClient->__construct(Array)
#4 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): Aligent\EventBridge\Service\EventBridgeNotifier->__construct(Object(Magento\Framework\Serialize\Serializer\Json), Object(Magento\Framework\Encryption\Encryptor), Object(Magento\Framework\Logger\LoggerProxy), Object(Aligent\EventBridge\Model\Config))
#5 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Aligent\\EventBr...', Array)
#6 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Aligent\\EventBr...')
#7 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(125): Magento\Framework\ObjectManager\Factory\Compiled->get('Aligent\\EventBr...')
#8 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(86): Magento\Framework\ObjectManager\Factory\Compiled->parseArray(Array)
#9 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Aligent\\AsyncEv...')
#10 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Aligent\\AsyncEv...')
#11 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Aligent\\AsyncEv...')
#12 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Aligent\\AsyncEv...')
#13 /app/ajrszs34qiro2_stg/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Compiled->create('Aligent\\AsyncEv...', Array)
#14 /app/ajrszs34qiro2_stg/vendor/magento/framework-message-queue/ConsumerFactory.php(92): Magento\Framework\ObjectManager\ObjectManager->create('Aligent\\AsyncEv...')
#15 /app/ajrszs34qiro2_stg/vendor/magento/framework-message-queue/ConsumerFactory.php(75): Magento\Framework\MessageQueue\ConsumerFactory->createConsumerConfiguration(Object(Magento\Framework\MessageQueue\Consumer\Config\ConsumerConfigItem))
#16 /app/ajrszs34qiro2_stg/vendor/magento/module-message-queue/Console/StartConsumerCommand.php(93): Magento\Framework\MessageQueue\ConsumerFactory->get('event.trigger.c...', 0)
#17 /app/ajrszs34qiro2_stg/vendor/symfony/console/Command/Command.php(255): Magento\MessageQueue\Console\StartConsumerCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /app/ajrszs34qiro2_stg/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /app/ajrszs34qiro2_stg/vendor/magento/framework/Interception/Interceptor.php(138): Magento\MessageQueue\Console\StartConsumerCommand\Interceptor->___callParent('run', Array)
#20 /app/ajrszs34qiro2_stg/vendor/magento/framework/Interception/Interceptor.php(153): Magento\MessageQueue\Console\StartConsumerCommand\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /app/ajrszs34qiro2_stg/generated/code/Magento/MessageQueue/Console/StartConsumerCommand/Interceptor.php(23): Magento\MessageQueue\Console\StartConsumerCommand\Interceptor->___callPlugins('run', Array, Array)
#22 /app/ajrszs34qiro2_stg/generated/code/Magento/MessageQueue/Console/StartConsumerCommand/Proxy.php(143): Magento\MessageQueue\Console\StartConsumerCommand\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /app/ajrszs34qiro2_stg/vendor/symfony/console/Application.php(1021): Magento\MessageQueue\Console\StartConsumerCommand\Proxy->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /app/ajrszs34qiro2_stg/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Magento\MessageQueue\Console\StartConsumerCommand\Proxy), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /app/ajrszs34qiro2_stg/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /app/ajrszs34qiro2_stg/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /app/ajrszs34qiro2_stg/bin/magento(23): Symfony\Component\Console\Application->run()
#28 {main} [] []

These changes do the following:

  • Move the creation of the AWS EventBridge Client class out of the constructor of the notifier class, so that it is only created when actually needed.
  • Check that config values are set before creating the class. If not, just return as unsuccessful.

 - Also check all necessary config values are set
Copy link
Contributor

@gowrizrh gowrizrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aligent-lturner aligent-lturner merged commit c4e6ed1 into main May 8, 2023
@aligent-lturner aligent-lturner deleted the fix/eventbridge_constructor branch May 8, 2023 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants