This commit is contained in:
2021-03-29 17:47:13 +08:00
parent ec101543c9
commit 442386866d
7 changed files with 44 additions and 46 deletions
+5 -1
View File
@@ -6,7 +6,9 @@ namespace Rpc;
use Exception;
use Snowflake\Abstracts\Component;
use Snowflake\Channel;
use Snowflake\Core\Json;
use Snowflake\Snowflake;
use Swoole\Coroutine\Client as CClient;
@@ -90,7 +92,9 @@ class Client extends Component
*/
public function getClient(): CClient
{
return objectPool(CClient::class, function () {
/** @var Channel $channel */
$channel = Snowflake::app()->get('channel');
return $channel->pop(CClient::class, function () {
$client = new CClient($this->config['mode'] ?? SWOOLE_SOCK_TCP);
$client->set([
'timeout' => 0.5,