RetryStrategyInterface.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpClient\Retry;
  11. use Symfony\Component\HttpClient\Response\AsyncContext;
  12. use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
  13. /**
  14. * @author Jérémy Derussé <jeremy@derusse.com>
  15. * @author Nicolas Grekas <p@tchwork.com>
  16. */
  17. interface RetryStrategyInterface
  18. {
  19. /**
  20. * Returns whether the request should be retried.
  21. *
  22. * @param ?string $responseContent Null is passed when the body did not arrive yet
  23. *
  24. * @return bool|null Returns null to signal that the body is required to take a decision
  25. * @param \Symfony\Component\HttpClient\Response\AsyncContext $context
  26. * @param \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface|null $exception
  27. */
  28. public function shouldRetry($context, $responseContent, $exception);
  29. /**
  30. * Returns the time to wait in milliseconds.
  31. * @param \Symfony\Component\HttpClient\Response\AsyncContext $context
  32. * @param string|null $responseContent
  33. * @param \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface|null $exception
  34. */
  35. public function getDelay($context, $responseContent, $exception);
  36. }