producers)) { $this->producers = Config::get('rpc.producers'); } if (empty($this->producers)) { return $this->addError('Empty by rpc service'); } if (!isset($this->producers[$name])) { return $this->addError('Unknown rpc service'); } $rand = $this->producers[$name][array_rand($this->producers[$name])]; if (Snowflake::app()->has($this->getName($name, $rand))) { return Snowflake::app()->get($this->getName($name, $rand)); } return Snowflake::app()->set($this->getName($name, $rand), [ 'class' => Client::class, 'config' => $rand ]); } /** * @param $name * @return Client|bool * @throws ReflectionException * @throws ComponentException * @throws ConfigException * @throws NotFindClassException */ public function __get($name): Client|bool { return $this->get($name); // TODO: Change the autogenerated stub } /** * @param $name * @param $rand * @return string */ private function getName($name, $rand): string { return 'rpc.client.' . $name . '.' . $rand['host']; } }