diff --git a/CHANGELOG.md b/CHANGELOG.md index 397a35dff..16bdff25c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## Fixed - [#1049](https://github.com/hyperf/hyperf/pull/1049) Fixed `Hyperf\Cache\Driver\RedisDriver::clear` sometimes fails to delete all caches. +- [#1085](https://github.com/hyperf/hyperf/pull/1085) Fixed broken retry annotation ## Optimized diff --git a/src/retry/src/Annotation/Retry.php b/src/retry/src/Annotation/Retry.php index aaa5c14eb..34dcab979 100644 --- a/src/retry/src/Annotation/Retry.php +++ b/src/retry/src/Annotation/Retry.php @@ -18,8 +18,10 @@ use Hyperf\Retry\Policy\ClassifierRetryPolicy; use Hyperf\Retry\Policy\FallbackRetryPolicy; use Hyperf\Retry\Policy\MaxAttemptsRetryPolicy; use Hyperf\Retry\Policy\SleepRetryPolicy; +use Hyperf\Retry\RetryBudget; use Hyperf\Retry\RetryBudgetInterface; use Hyperf\Retry\SleepStrategyInterface; +use Hyperf\Utils\ApplicationContext; /** * @Annotation @@ -117,7 +119,11 @@ class Retry extends AbstractRetry { parent::__construct($value); if (is_array($this->retryBudget)) { - $this->retryBudget = make(RetryBudgetInterface::class, $this->retryBudget); + if (ApplicationContext::hasContainer() && ApplicationContext::getContainer()->has(RetryBudgetInterface::class)){ + $this->retryBudget = make(RetryBudgetInterface::class, $this->retryBudget); + } else { + $this->retryBudget = make(RetryBudget::class, $this->retryBudget); + } } } }