/**
* Add fault tolerance to the request.
*
* @param string|array $request
*
* @return array
*/
protected function sendWithTolerance($request)
{
$operation = new Callback(function () use($request) {
return $request->send();
});
// Creates the strategy used to wait between failing calls
$waitStrategy = new CountLimited(new ExponentialBackOff(new SleepWaiter(), $request->timeUntilNextTry), $request->triesUntilFailure);
// Creates the runner
$runner = new RetryOperationRunner(new CallbackOperationRunner(), $waitStrategy);
return $runner->run($operation);
}