mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed bug that retry_interval does not work for rpc-multiplex
. (#3794)
This commit is contained in:
parent
29fca4319b
commit
1b2cb6aa18
@ -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`.
|
||||
|
@ -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();
|
||||
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user