Fixed bug that retry_interval does not work for rpc-multiplex. (#3794)

This commit is contained in:
李铭昕 2021-07-09 20:45:20 +08:00 committed by GitHub
parent 29fca4319b
commit 1b2cb6aa18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -84,3 +84,4 @@
- [#3769](https://github.com/hyperf/hyperf/pull/3769) Fixed bug that `config-center` conflicts with `metrics`.
- [#3770](https://github.com/hyperf/hyperf/pull/3770) Fixed type error when using `Str::slug()`.
- [#3788](https://github.com/hyperf/hyperf/pull/3788) Fixed type error when using `BladeCompiler::getRawPlaceholder()`.
- [#3794](https://github.com/hyperf/hyperf/pull/3794) Fixed bug that `retry_interval` does not work for `rpc-multiplex`.

View File

@ -41,7 +41,7 @@ class Transporter implements TransporterInterface
],
'recv_timeout' => 5.0,
'retry_count' => 2,
'retry_interval' => 100,
'retry_interval' => 0,
'client_count' => 4,
];
@ -55,6 +55,7 @@ class Transporter implements TransporterInterface
public function send(string $data)
{
$retryCount = $this->config['retry_count'] ?? 2;
$retryInterval = $this->config['retry_interval'] ?? 0;
$result = retry($retryCount, function () use ($data) {
try {
return $this->factory->get()->request($data);
@ -65,7 +66,7 @@ class Transporter implements TransporterInterface
return new ExceptionThrower($exception);
}
});
}, $retryInterval);
if ($result instanceof ExceptionThrower) {
throw $result->getThrowable();

View File

@ -39,6 +39,7 @@ class TransporterTest extends AbstractTestCase
$transporter = new Transporter($container, [
'connect_timeout' => $timeout = rand(50, 100),
'retry_interval' => 123,
]);
$invoker = new ClassInvoker($transporter);
@ -46,5 +47,7 @@ class TransporterTest extends AbstractTestCase
$factory = new ClassInvoker($invoker->factory);
$this->assertSame($timeout, $factory->config['connect_timeout']);
$this->assertSame(123, $factory->config['retry_interval']);
}
}