Merge pull request #1085 from Reasno/retry

fix issue #1069 which breaks retry annotation
This commit is contained in:
谷溪 2019-12-05 09:26:33 +08:00 committed by GitHub
commit c88e5ca32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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);
}
}
}
}