RetryStrategyInterface.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. */
  26. public function shouldRetry(AsyncContext $context, ?string $responseContent, ?TransportExceptionInterface $exception): ?bool;
  27. /**
  28. * Returns the time to wait in milliseconds.
  29. */
  30. public function getDelay(AsyncContext $context, ?string $responseContent, ?TransportExceptionInterface $exception): int;
  31. }