This commit is contained in:
2021-03-24 19:02:43 +08:00
parent 7c7a7f4d6e
commit db3c28169a
+7 -6
View File
@@ -116,21 +116,22 @@ class Producer extends Component
/** /**
* @param string $name * @param string $name
* @param array|null $config * @param string|null $host
* @return mixed * @return mixed
* @throws ReflectionException
* @throws ComponentException * @throws ComponentException
* @throws NotFindClassException * @throws NotFindClassException
* @throws ReflectionException
* @throws Exception * @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) { if ($producer === null) {
throw new Exception('Unknown rpc client config.'); throw new Exception('Unknown rpc client config.');
} }
if (!empty($host)) {
if (!isset($producer['host'])) { $producer['host'] = $host;
} else if (!isset($producer['host'])) {
$producer['host'] = Snowflake::localhost(); $producer['host'] = Snowflake::localhost();
} }
$producerName = $this->getName($name, $producer); $producerName = $this->getName($name, $producer);