简体   繁体   English

带有Guzzle的MultiCurl的Amazon AWS PHP SDK?

[英]Amazon AWS PHP SDK with Guzzle's MultiCurl?

I need to perform some fairly heavy queries with Amazon's AWS SDK for PHP. 我需要使用Amazon的适用于PHP的AWS开发工具包执行一些相当繁琐的查询。
The most efficient way would be to use PHP's MultiCurl . 最有效的方法是使用PHP的MultiCurl It seems that Guzzle already has functionality for MultiCurl built in. 似乎Guzzle已经具有内置的MultiCurl功能。

Does using the standard methods provided by the AWS SDK automatically use MultiCurl or do I have to specify it's usage directly? 使用AWS开发工具包提供的标准方法会自动使用MultiCurl还是必须直接指定其用途? Eg calling $sns->Publish() 30 times. 例如,调用$sns->Publish() 30次。

Thanks! 谢谢!

Parallel requests work exactly the same in the SDK as in plain Guzzle and do take advantage of MultiCurl. 并行请求在SDK中的工作原理与普通Guzzle完全相同,并且确实利用了MultiCurl。 For example, you could do something like this: 例如,您可以执行以下操作:

$message = 'Hello, world!';
$publishCommands = array();
foreach ($topicArns as $topicArn) {
    $publishCommands[] = $sns->getCommand('Publish', array(
        'TopicArn' => $topicArn,
        'Message'  => $message,
    ));
}

try {
    $successfulCommands = $sns->execute($publishCommands);
    $failedCommands = array();
} catch (\Guzzle\Service\Exception\CommandTransferException $e) {
    $successfulCommands = $e->getSuccessfulCommands();
    $failedCommands = $e->getFailedCommands();
}

foreach ($failedCommands as $failedCommand) { /* Handle any errors */ }

$messageIds = array();
foreach ($successfulCommands as $successfulCommand) {
    $messageIds[] = $successfulCommand->getResult()->get('MessageId');
}

// Also Licensed under version 2.0 of the Apache License.

The AWS SDK for PHP User Guide has more information about working with command objects in this way. 适用于PHPAWS开发工具包用户指南提供了有关以这种方式使用命令对象的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM