From db3c28169a214a2a0cd95122b427ee7c150f33c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 24 Mar 2021 19:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rpc/Producer.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Rpc/Producer.php b/Rpc/Producer.php index cca6bf86..74105f83 100644 --- a/Rpc/Producer.php +++ b/Rpc/Producer.php @@ -116,21 +116,22 @@ class Producer extends Component /** * @param string $name - * @param array|null $config + * @param string|null $host * @return mixed - * @throws ReflectionException * @throws ComponentException * @throws NotFindClassException + * @throws ReflectionException * @throws Exception */ - public function getClient(string $name, array $config = null): Client + public function getClient(string $name, string $host = null): Client { - $producer = $config ?? $this->producers[$name] ?? null; + $producer = $this->producers[$name] ?? null; if ($producer === null) { throw new Exception('Unknown rpc client config.'); } - - if (!isset($producer['host'])) { + if (!empty($host)) { + $producer['host'] = $host; + } else if (!isset($producer['host'])) { $producer['host'] = Snowflake::localhost(); } $producerName = $this->getName($name, $producer);