~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/guzzlehttp/guzzle/src/Adapter/FakeParallelAdapter.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
namespace GuzzleHttp\Adapter;
 
3
 
 
4
use GuzzleHttp\Exception\RequestException;
 
5
 
 
6
/**
 
7
 * Decorates a regular AdapterInterface object and creates a
 
8
 * ParallelAdapterInterface object that sends multiple HTTP requests serially.
 
9
 */
 
10
class FakeParallelAdapter implements ParallelAdapterInterface
 
11
{
 
12
    /** @var AdapterInterface */
 
13
    private $adapter;
 
14
 
 
15
    /**
 
16
     * @param AdapterInterface $adapter Adapter used to send requests
 
17
     */
 
18
    public function __construct(AdapterInterface $adapter)
 
19
    {
 
20
        $this->adapter = $adapter;
 
21
    }
 
22
 
 
23
    public function sendAll(\Iterator $transactions, $parallel)
 
24
    {
 
25
        foreach ($transactions as $transaction) {
 
26
            try {
 
27
                $this->adapter->send($transaction);
 
28
            } catch (RequestException $e) {
 
29
                if ($e->getThrowImmediately()) {
 
30
                    throw $e;
 
31
                }
 
32
            }
 
33
        }
 
34
    }
 
35
}