Example #1
0
 /**
  * Constructor.
  *
  * @param string $backend Backend type, currently 'mysql' or 'redshift' is accepted.
  * @param string $token Storage API token.
  * @param string $runId Storage API run Id.
  * @param string $url
  */
 public function __construct($backend, $token, $runId, $url = 'https://syrup.keboola.com/provisioning')
 {
     $this->setBackend($backend);
     $this->setToken($token);
     $this->setRunId($runId);
     $client = new \Guzzle\Http\Client($url);
     $client->getConfig()->set('curl.options', array(CURLOPT_TIMEOUT => $this->timeout));
     $maintenanceBackoff = new BackoffPlugin(new TruncatedBackoffStrategy(10, new MaintenanceBackoffStrategy(array(503), new CurlBackoffStrategy(CurlBackoffStrategy::getDefaultFailureCodes(), new ExponentialBackoffStrategy()))));
     $client->addSubscriber($maintenanceBackoff);
     $this->client = $client;
 }
 public function testIgnoresNonErrors()
 {
     $strategy = new CurlBackoffStrategy();
     $request = $this->getMock('Guzzle\\Http\\Message\\Request', array(), array(), '', false);
     $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, new Response(200)));
 }